Vineeth Paliath
Posts: 34
Joined: 2009-06-19
|
Hi,
i am developing a com add-in using c#2008 add-in express, when i try to add a picture in word,
Word.Application wordApp = new Word.Application();
wordApp.ActiveDocument is always null and documents.count=0, so i add a new document to word application, it will open a new word and insert picture in that word document. so how can insert a picture in the current word document
Word.Application wordApp = new Word.Application();
if (wordApp.ActiveDocument == null)
wordApp.Documents.Add(ref missing, ref typefalse, ref missing, ref typeTrue);
wordApp.ActiveDocument.Shapes.AddPicture(fileName, ref typeTrue, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
wordApp.Visible = true;
Thanks
|
|
Andrei Smolin
Add-in Express team
Posts: 18793
Joined: 2006-05-11
|
Hi Vineeth,
I'm afraid Word.Application wordApp = new Word.Application() creates a new Word application and this isn't what you want. Use the WordApp property from your add-in module. Then use:
wordApp.ActiveDocument.Shapes.AddPicture(fileName, ref typeTrue, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
Andrei Smolin
Add-in Express Team Leader |
|