How can I add a picture to a word document without loosing quality using the Microsoft.Office.Interop.Word
assembly?
The common way to insert a picture to word document is:
Application wordApp = new Application();
Document wordDoc = wordApp.Documents.Add();
Range docRange = wordDoc.Range();
string imageName = @"c:\temp\win10.jpg";
InlineShape pictureShape = docRange.InlineShapes.AddPicture(imageName);
wordDoc.SaveAs2(@"c:\temp\test.docx");
wordApp.Quit();
This way compresses the picture.
There are optional LinkToFile
and SaveWithDocument
parameters but the saved image is compressed and a link is not wanted because picture file mustn't exist externally.
For Excel there is the Shapes.AddPicture2
Method with MsoPictureCompress
parameter which seems to be for this. But I cannot find any equivalent for Word.