How can I allow a user to define the file name and directory when saving a Microsoft Word file?
1 次查看(过去 30 天)
显示 更早的评论
I wrote some code to create a Microsoft Word document and write some data inside it. The code below doesn't allow users to choose the directory and filename. In the GUI I have a pushbutton, I would like the allow the user to define the directory and file name. How I can change this GUI code to allow this?
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)
0 个评论
采纳的回答
Jan
2013-7-27
编辑:Jan
2013-7-27
[fileName, filePath] = uiputfile('*.doc', 'Create a file:')
if ~ischar(fileName)
return;
end
fileID = fopen(fullfile(filePath, fileName), 'w');
Note, that the shown method does not create a MS-Word file, but a standard text file. But MS-Word can open such files also.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!