I have been investigating and I would like to use the option from MS Word of inserting a Word file in order to perform the merge. To learn how to use it, I have recorded a macro performing this activity on Word, and the resulting code is the following:
Selection.InlineShapes.AddOLEObject( ClassType:="Word.Document.12", FileName:="C:\Users\mangeles.delacruz\Desktop\Test\Doc1.docx", LinkToFile :=False, DisplayAsIcon:=False)
I´m trying to call this function from matlab but I get errors all the time... I´m not very familiar with actxserver with Word... This is the code I´m writing:
wordaplication = actxserver('Word.Application');
wordaplication.Visible = 1; %Word visible or not, put 0 if it is not desired to see the docx editing
doc=invoke(wordaplication.Documents,'Add','D:\Test_Report.docx');
selection = wordaplication.Selection;
selection.InlineShapes.AddOLEObject('C:\Users\mangeles.delacruz\Desktop\SW RFSCOE\hola.docx',0,0);
Then I get a message on the word document saying "word cannot obtain data from link 0". I clic on accept and then I also get the following error on Matlab console:
Error using Interface.Microsoft_Word_14.0_Object_Library.InlineShapes/AddOLEObject
Error in pruebasWords (line 15)
selection.InlineShapes.AddOLEObject('C:\Users\mangeles.delacruz\Desktop\SW RFSCOE\hola.docx',0,0);
I think this function is the key to solve my need... but I´m not using it right.
Anybody with more experience can help?
Thank you!!