Word COM - writing text into this open document
Afficher commentaires plus anciens
I need to know how to write text into an open Word document. I used this code to open the word application:
word = actxserver('word.application');
set(word,'visible',1);
doc1 = invoke(word.documents,'add');
invoke(doc1.paragraphs,'add');
range = invoke(doc1,'range',doc1.Paragraphs.Item(1).range.Start);
I need to write several lines of text and two plots into this document. How do I do this?
Réponse acceptée
Plus de réponses (3)
Kaustubha Govind
le 17 Fév 2011
2 votes
Once you start Word as a COM server from MATLAB, it is basically just a matter of invoking methods from the MS Word COM API. The Reference is here: http://msdn.microsoft.com/en-us/library/ff841702.aspx
1 commentaire
Feng Guo
le 31 Juil 2018
These methods were what I was trying to find, thanks a lot!
Kevin O'Hara
le 17 Fév 2011
0 votes
Robert
le 11 Nov 2011
0 votes
Hello,
I'm also trying to open a certain word-file and to add some graphics. At the moment it is possible to open a certain existing word-document. I would like to ask you to give me an example how to add a new page in this document to add a new graphic. How can I also select a certain page of the word document?
kind regards,
Robert
1 commentaire
Eric
le 23 Nov 2011
To go to a particular page you should be able to use something like:
wdGoToPage = 1;
wdGoToNext = 2;
Word_COM.Selection.GoTo(wdGoToPage, wdGoToNext, 1, desired_page);
where desired_page is the page number you want.
To insert a page break you can use
wdPageBreak = 7;
Word_COM.Selection.InsertBreak(wdPageBreak);
Good luck,
Eric
Catégories
En savoir plus sur Use COM Objects in MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!