简体   繁体   中英

Replace MS Word bookmark with HTML content C# .NET

I have MS Word template with content inside. In the middle of the content I have a specific bookmark that I want to replace with HTML file (not the tags view, all the visual view). What is the easiest way to do it? I found the option to insert a file but couldn't find to insert it to a specific place instead of a bookmark. Thanks.

Use a Range object with the InsertFile method. For example the following code will insert a file where the bookmark is:

Word.Range rngBookmark = wdDoc.Bookmarks["test"].Range;
rngBookmark.InsertFile(filePath);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM