问题
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
;
回答1:
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
来源:https://stackoverflow.com/questions/29400201/how-to-insert-image-in-a-existing-word-document-with-c-sharp