Arnab
Arnab

Reputation: 271

How to insert image in a existing word document with c#

I am working with word and c# . taking the snap shot with my code and saving it in a particular folder (ex.C:\Temp). now i want to save the image to an existing word document.any kind of help with short code sample is highly appreciated .
Will prefer to use Microsoft.Office.Interop.Word;

Upvotes: 2

Views: 18754

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49455

Of course, the Word object model provides the required methods for inserting an image into the document. To add a picture at the cursor location you just need to call the AddPicture method of the InlineShapes collection and pass in the name of the file.

 Application.Selection.InlineShapes.AddPicture(@"C:\SamplePicture.jpg");

See How to: Programmatically Add Pictures and Word Art to Documents for more information.

Also you may consider using the Open XML SDK. Take a look at the following articles in MSDN:

Upvotes: 3

Related Questions