I am writing a matlab code which, after calculation, prints a report in pdf format. I am using actxserver for communicating with Microsoft Word. The user inputs the filename of the final report and it gets saved in a folder which is predefined.
I am using,
name = input('Please enter the filename','s');
WordFileName=name;
FileSpec = fullfile(pwd,WordFileName);
[ActXWord,WordHandle]=StartWord(FileSpec);
function [actx_word,word_handle]=StartWord(word_file_p)
actx_word = actxserver('Word.Application');
word_handle = invoke(actx_word.Documents,'Add');
end
function CloseWord(actx_word_p,word_handle_p,word_file_p)
word_handle_p.ExportAsFixedFormat(word_file_p,17);
end
When the user inputs : report , the pdf gets generated as report.pdf
but when the filename has another characters like for example '1.2MFQ', a file gets generated with filename '1.2MFQ' and filetype '2MFQ' with no pdf extension.
Is this because of the input in matlab or during printing as pdf?
I think that's word doing it and not Matlab. Why not just append .pdf to the file name string in the beginning:
FileSpec = fullfile(pwd,[WordFileName, ".pdf"]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.