The range cannot be deleted. at Microsoft.Office.Interop.Word.Range.set_Text(String prop)

后端 未结 2 1425
梦谈多话
梦谈多话 2021-01-17 15:24

The recommended c# .net code to replace a bookmark with text appears very straight forward and I have seen the same code all over the net on so many websites (including your

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-17 15:45

    Instead of altering the range directly, try something like:

    Bookmark bookmark = doc.Bookmarks.get_Item(ref name);
    
    //Select the text.
    bookmark.Select();
    
    //Overwrite the selection.
    wordApp.Selection.TypeText(text);
    

    E.g. use your Word application instance to alter the document instead.

提交回复
热议问题