We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cannot find bookmark 'Name' in the document when bookmark occurs later in the document

When I call Remove() on a bookmark that has been found but is later in the document, an exception is thrown "
Cannot find bookmark ‘Bookmark_Name’ in the document.
at .(Node , String , BookmarkStart )
at Aspose.Words.Bookmark.get_BookmarkEnd()
at Aspose.Words.Bookmark.()
at Aspose.Words.Bookmark.set_Text(String value)
I am using an version of the library without applying the license. We will be purchasing the library shortly.

However, we need to be sure the library can remove bookmarks correctly.
The library should return null if the bookmark is not found. Otherwise it should be able to set text.
When I move the bookmark earlier in the document it works.
Then I add a paragraph and the error occurs.
Are there limitations which would be resolved with the paid version or is this a bug?


Have you tried the latest version of Aspose.Words for .NET i.e. 19.10 on your end? In case the problem still remains, please ZIP and upload your simplified input Word documenthere for testing. We will then investigate the issue on our end and provide you more information.

Hello Awais,

Thank you for your response. It would take some time to deidentify the document I have, so if I do not resolve the issue on my own I will do so and post it.

Would it be possible to answer the question I posed? That is, are there limitations on bookmarks which would be resolved after moving to fully licensed status?

So far it looks like that when the document is truncated due to the library being in “Evaluation Only”, when a bookmark starts within the output document and ends after the document was truncated, then the bookmark can be found with document.Range.Bookmarks[bookmarkName], but errors when bookmark.BookmarkEnd is called. This happens when the method bookmark.BookmarkEnd is called directly or via bookmark.Text = "" or bookmark.Remove().

Kind regards,



Yes, this is possible and your understanding is correct that Aspose.Words will truncate BookmarkEnd and invoking bookmark.BookmarkEnd will result in a System.InvalidOperationException. However, the licensed version of Aspose.Words will not cause any such problems. In case you have further inquiries or need any help, please let us know.
Evaluate Aspose.Words - Limitations