2

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;

user2526236
  • 1,538
  • 2
  • 15
  • 29
Arnab
  • 271
  • 2
  • 7
  • 18

1 Answers1

3

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:

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • HI @Eugene Thanks for your help.As per your advice i developed the below method to open an existing word doc and inserting image into it but new images are coming top of old images with this.Can you suggest anything so that the old one will display first and the newest will at buttom ? http://stackoverflow.com/questions/30539513/not-able-to-insert-image-after-the-current-one-in-word-with-microsoft-office-int – Arnab May 29 '15 at 22:02
  • Another helpful link: http://www.neodynamic.com/ND/FaqsTipsTricks.aspx?tabid=66&prodid=3&sid=36 The section titled "How to insert barcode images with DPI support" was especially useful to me. – David Jun 24 '16 at 17:13