Programmatically insert image to word with link to file

夙愿已清 提交于 2020-01-25 12:49:48

问题


In Word document, there is an option in the insert image dialog box insert button that is "Link to File", where I can input a image url link into the file name input box. Word will then pull that image from the link. As such everytime the user opens the word document, it will pull that image from the link.

How do i do that with Microsoft Interop? Ive tried to use this method http://www.c-sharpcorner.com/uploadfile/hrojasara/insert-picture-with-hyperlink-in-word-file-using-C-Sharp/

However it saves the image to the file which i do not want to.

Hope someone can help. Thanks!


回答1:


Look at the documentation for the .AddPicture Method (https://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.inlineshapes.addpicture(v=office.15).aspx);

InlineShape AddPicture(
    string FileName,
    ref Object LinkToFile,
    ref Object SaveWithDocument,
    ref Object Range
)

You can easily set the parameters to achieve the desired results.



来源:https://stackoverflow.com/questions/32322438/programmatically-insert-image-to-word-with-link-to-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!