I wrote codes which create a microsoft word and writes something inside it. I want to create a pushbutton which enables users to choose filename and directory to saving this file.
1 view (last 30 days)
Show older comments
parameters = 0:.1:1
A = [ parameters ; exp( parameters )]
fileID = fopen('results.doc','w')
fprintf(fileID,'%6s %12s\n','parameters ','rms')
fprintf(fileID,'%6.2f %30.8f\n',A)
fclose(fileID)
%as you see that users cannot choose directory or filename in these codes. I want to create a pushbutton in GUI for saving this doc file. When users push the button a dialog box which enables users to choose filename and directory for saving this file needs to open.
What kind of codes I need?
0 Comments
Accepted Answer
Image Analyst
on 27 Jul 2013
Use GUIDE to create a GUI. Place a pushbutton on your form. In the callback function for the pushbutton, put this code:
% Get the name of the file that the user wants to save.
startingFolder = userpath % or wherever you want
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
2 Comments
Image Analyst
on 28 Jul 2013
That's a totally different question. To do that you need to use ActiveX. Search this forum for ActiveX and you'll find lots of examples, mainly on Excel though.
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!