How to transfer a series of Word files to pdf files?

12 ビュー (過去 30 日間)
DY
DY 2021 年 9 月 6 日
編集済み: Yongjian Feng 2021 年 9 月 6 日
It's annoying to open Word file one by one and save as pdf files manually. How to realize word2pdf function by matlab scripts?

回答 (1 件)

Yongjian Feng
Yongjian Feng 2021 年 9 月 6 日
編集済み: Yongjian Feng 2021 年 9 月 6 日
matlab doesn't have word2pdf function. Implement your own word2pdf function like below following this link, then you can just
files = dir('*.docx');
for i=1:length(files)
file = files(i);
word2pdf(file);
end
It will convert all the word docs in the current folder into pdfs.
Your word2pdf could be a script like this:
function word2pdf(infile)
wrd = actxserver('word.application');
wrdDoc = wrd.Documents;
wrdFile = wrdDoc.Open(infile);
[fPath, fName, fExt] = fileparts(infile);
outfile = fullfile(fPath, [fName '.pdf']);
wrdFile.SaveAs2(outfile,17);
wrdDoc.Close;
wrd.Quit();
end

カテゴリ

Help Center および File ExchangeHelp and Support についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by