Add picture to current word document

Add-in Express™ Support Service
That's what is more important than anything else

Add picture to current word document
 
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


Posted 24 Jun, 2009 04:08:31 Top
Andrei Smolin


Add-in Express team


Posts: 16061
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); 


Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 24 Jun, 2009 07:13:50 Top