This is an example to learn how to control Microsoft Word in Matlab.
(tested on Microsoft Office 2007)
This example contains:
-define Font Size
-define Page setup
-change format of text
-insert figures from Matlab as picture in Word
-insert picture from file
Stefan Braun (2020). ActiveX Word control base commands (https://www.mathworks.com/matlabcentral/fileexchange/56283-activex-word-control-base-commands), MATLAB Central File Exchange. Retrieved .
With your code I finally learned how to align the text and how to paste a figure directly from matlab and from a folder.
I was having issues with the SaveAs function but found adding '2' after worked:
Also the font color part didn't work for me but this did:
selection.Font.TextColor.RGB = 16777215
Thanks for these informations, nevertheless, I need to insert a equation in document (.docx). Do you Know How I make it? I was not successful to use a class OMaths.
It does not run and I get this error:
The 'Color' property name is ambiguous in the '00020952_0000_0000_C000_000000000046' class.
Error in Word_example (line 85)
I need to know how to format the page setup to "landscape" format - couldn`t find it in the examples and overview.
Can someone help?
@Mark Breutzman perhaps this could help:
I'm trying to adapt this for my own purpose, but keep having problems with SaveAs:
Cannot find an exact (case-sensitive) match for 'SaveAs'
The closest match is: saveas in C:\Program Files\MATLAB\R2016b\toolbox\matlab\general\saveas.m
Error in Word_example (line 241)
document.SaveAs([pwd '/test.doc']); %save Document
What am I missing?
- added missing files
-added html file
-added AddPicture command