How to insert image in a existing word document with c#
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:
- How to: Insert a picture into a word processing document (Open XML SDK)
- Adding Images to Documents in Word 2007 by Using the Open XML SDK 2.0 for Microsoft Office
Arnab
Professional Tester , Passionate developer and Hobbyist photographer.
Updated on June 04, 2022Comments
-
Arnab almost 2 years
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 useMicrosoft.Office.Interop.Word
;