WordDocument document = new WordDocument(@"testTab.docx", FormatType.Docx);
//Creates the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Moves the virtual cursor to the location before the end of the bookmark "Col1"
bookmarkNavigator.MoveToBookmark("Col1");
//Replaces the bookmark content
bookmarkNavigator.ReplaceBookmarkContent("Column 1",true);
//Moves the virtual cursor to the location before the end of the bookmark "Col2"
bookmarkNavigator.MoveToBookmark("Col2");
//Replaces the bookmark content
bookmarkNavigator.ReplaceBookmarkContent("Column 2", true);
document.Save("Sample.docx", FormatType.Docx);
document.Close(); |