Writing PDF files - problem with MSWord automation in compiled executable
Afficher commentaires plus anciens
Hi
I'm having a problem getting MSWord automation to work when the code is compiled as an executable
I have a Matlab program that generates an HTML file, as a final step I want to save this as PDF. The function below works fine when running in Matlab, but the executable generated by mcc has an error at the SaveAs2 step. (All the other statements work fine in the executable.)
doc.SaveAs2(pdfFile,17);
--- Attempt to reference field of non-structure array.
I've also tried the alternative syntax which also works in Matlab, but this produces a different error in the executable.
SaveAs2(doc,pdfFile,17);
--- Undefined function 'SaveAs2' for input arguments of type 'double'.
Any suggestions would be greatly appreciated. Thanks Neil Caithness
function html2pdf(htmlFile,pdfFile)
% Open Word
wordApplication = actxserver('Word.Application');
% Uncomment this for debugging
% set(wordApplication,'Visible',1);
% Get a handle to the documents object
documents = wordApplication.Documents;
% Open the Document
doc = documents.Open(htmlFile);
% Save it as PDF
doc.SaveAs2(pdfFile,17);
% Close the document
doc.Close;
% Close Word
wordApplication.Quit;
MATLAB Version 7.12.0.635 (R2011a) MATLAB License Number: xxxx Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1) Java VM Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot™ 64-Bit Server VM mixed mode
Microsoft Office Professional Plus 2010 Version 14.0.6112.5000 (64-bit)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!