Word document “Saveas2()” method no longer working
As of the past few days, I seem to be no longer able to save word documents created through matlab. Several months ago I ran the following script which opens an existing word document and saves it as another document.
reportPath = ‘Table_out.docx’;
templateName = append(pwd, ‘Table_Inject_Test.docx’);
actx_word = actxserver(‘Word.Application’);
actx_word.Visible = true;
trace(actx_word.Visible);
wordTemplate = actx_word.Documents.Open(templateName); % Open template
wordTemplate.SaveAs2(reportPath); % Save copy as report
Once I started getting this error in another project, I reverted back to this script to check it wasn’t something I had done within the word template to cause the error.
However when I try to run the same script now, I get the following error:
% Unrecognized method, property, or field ‘SaveAs2’ for class
% ‘Interface.0002096B_0000_0000_C000_000000000046’.
% Error in tableinjecttest2 (line 7)
% wordTemplate.SaveAs2(reportPath); % Save copy as report
Has something changed within the WordInterface object? I see there is a ‘saveobj’ method but that doesn’t seem to save the document either. That just gives me a different error:
% Unable to resolve the name ‘wordParent.saveobj’.
%
% Error in tableInjectTest (line 22)
% wordTemplate.saveobj(reportPath)As of the past few days, I seem to be no longer able to save word documents created through matlab. Several months ago I ran the following script which opens an existing word document and saves it as another document.
reportPath = ‘Table_out.docx’;
templateName = append(pwd, ‘Table_Inject_Test.docx’);
actx_word = actxserver(‘Word.Application’);
actx_word.Visible = true;
trace(actx_word.Visible);
wordTemplate = actx_word.Documents.Open(templateName); % Open template
wordTemplate.SaveAs2(reportPath); % Save copy as report
Once I started getting this error in another project, I reverted back to this script to check it wasn’t something I had done within the word template to cause the error.
However when I try to run the same script now, I get the following error:
% Unrecognized method, property, or field ‘SaveAs2’ for class
% ‘Interface.0002096B_0000_0000_C000_000000000046’.
% Error in tableinjecttest2 (line 7)
% wordTemplate.SaveAs2(reportPath); % Save copy as report
Has something changed within the WordInterface object? I see there is a ‘saveobj’ method but that doesn’t seem to save the document either. That just gives me a different error:
% Unable to resolve the name ‘wordParent.saveobj’.
%
% Error in tableInjectTest (line 22)
% wordTemplate.saveobj(reportPath) As of the past few days, I seem to be no longer able to save word documents created through matlab. Several months ago I ran the following script which opens an existing word document and saves it as another document.
reportPath = ‘Table_out.docx’;
templateName = append(pwd, ‘Table_Inject_Test.docx’);
actx_word = actxserver(‘Word.Application’);
actx_word.Visible = true;
trace(actx_word.Visible);
wordTemplate = actx_word.Documents.Open(templateName); % Open template
wordTemplate.SaveAs2(reportPath); % Save copy as report
Once I started getting this error in another project, I reverted back to this script to check it wasn’t something I had done within the word template to cause the error.
However when I try to run the same script now, I get the following error:
% Unrecognized method, property, or field ‘SaveAs2’ for class
% ‘Interface.0002096B_0000_0000_C000_000000000046’.
% Error in tableinjecttest2 (line 7)
% wordTemplate.SaveAs2(reportPath); % Save copy as report
Has something changed within the WordInterface object? I see there is a ‘saveobj’ method but that doesn’t seem to save the document either. That just gives me a different error:
% Unable to resolve the name ‘wordParent.saveobj’.
%
% Error in tableInjectTest (line 22)
% wordTemplate.saveobj(reportPath) word application, actxserver MATLAB Answers — New Questions