Free Support Forum - aspose.com

Find Bookmarks and replace text within it

Hi,

Is it possible to replace the text within bookmarks? if so can you please let me know how?

Initially the document is created as

docBuilder.StartBookmark("ID");

docBuilder.InsertHtml(html);

docBuilder.EndBookmark("ID");

At a later point I would like to find this Bookmark and replace the html. I've been able to goto the bookmark but didn't know how to replace the text within the start and end of the bookmark

docBuilder.MoveToBookmark("ID");

Thanks.

Hello

Thanks for your request. MoveToBookmark method has three overloads. One of them allows you move the cursor to a bookmark with greater precision. Please see the following link to learn more:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.documentbuilder.movetobookmark_overload_2.html

You can remove old content from the bookmark using the following code:

// Clear bookmark

doc.Range.Bookmarks[ID].Text = string.Empty;

Best regards,