Trouble saving DOCX file as PDF: 'Undefined function or variable 'SaveAs2'.'
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi everyone,
I'm trying to save a DOCX document as PDF programatically from Matlab. I'm running the following code:
wrd = actxserver('word.application');
wrdDoc = wrd.Documents;
wrdFile = wrdDoc.Open('C:\MyFiles\myfile2.docx');
wrdFile.SaveAs2('C:\MyFiles\TestWord.pdf',17);
It gives me the following error: "Undefined function or variable 'SaveAs2'."
What am I doing wrong? All examples are using the SaveAs2 function....
I'm using Matlab 2016b and Word 2013.
Thank you all very much for your time and effort!
댓글 수: 2
Walter Roberson
2017년 1월 9일
Odd, I see that you are using the same sequence as documented in https://www.mathworks.com/matlabcentral/answers/103861-how-can-i-save-a-word-document-as-a-pdf-via-actxserver-in-matlab-8-2-r2013b
Unfortunately I cannot afford Office so I cannot test this. (The license agreements is distinctly unfavorable if you run on Windows on Virtual Machines like I do.)
Nikhil Sreekumar
2017년 1월 11일
Hi Aalaas,
I tried your code in MATLAB 2016b and Word 2016. The code works fine for me. I was able to generate the pdf file.
I was able to find a MATLAB Central query on similar lines. Please see if the below link helps:
Thanks
Nikhil
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!