嗨,我每次尝试使用“ Word应用程序”修改“书签文本”时都试图删除书签 我正在使用给定代码段的belove将书签添加到文档中
Word.Document currDocument = WordApp.ActiveDocument;
Word.Selection currentSelection = WordApp.Selection;
if(currentSelection.HeaderFooter.IsHeader)
{
Word.Range selectionRange = currentSelection.Range;
selectionRange.Text ="ANYTEXT";
currentDocument.Bookmarks.Add("bName", selectionRange);
}
现在,每当我尝试编辑书签文本(ANYTEXT)时,都应从该特定文本中删除书签。
答案 0 :(得分:0)
尝试以下示例
_Application word = new Application();
Document doc = word.Documents.Open(@"D:\Documents\Bookmarked.dot");
doc.Bookmarks["mybookmark"].Select();
word.Selection.TypeText("Replacement text");
((_Application)word).Quit(WdSaveOptions.wdSaveChanges, WdOriginalFormat.wdOriginalDocumentFormat);