Hi,
Thanks for your inquiry. Please check following code snippet for replacing bookmark. Hopefully it will serve the purpose. Please use MoveToBookmark() method for moving cursor to specific bookmark.
Hi,
Thanks for your feedback. It’s perfect that you managed to get your desired results.
As a reference, please find complete code and output document.
Document doc = new Document(MyDir+"bookmarktest.doc");
DocumentBuilder builder= new DocumentBuilder(doc);
Bookmark bm = doc.Range.Bookmarks["bm_1"];
builder.MoveToBookmark("bm_1",true,false);
builder.Underline = Underline.Single;
// documentbuilder writes underlined text in start of bookmark
builder.Write("hello");
// set text of bookmark. set to string.Empty for removing bookmark text.
bm.Text = "content";
// bm.Text = string.Empty;
// To remove bookmark
// bm.Remove();
doc.Save(MyDir+"out.doc");
Please feel free to contact us for any further assistance.
Best Regards,
Hi,
It’s good to hear that you have achieved your desired results. Please let us know for any further query. We will be more than happy to help you…
Best Regards,