Free Support Forum - aspose.com

Problem with complex bookmark text deletion

Hi,
thank you.
Unfortunately it works only with certain bookmarks.
With another document and another bookmark whose name is opz_tdet.
I found this exception:
BookmarkEnd 'bookmark.BookmarkEnd' threw an exception of type 'Aspose.Words.PleaseReportException'
Aspose.Words.BookmarkEnd {Aspose.Words.PleaseReportException}

Exception 'Cannot find bookmark 'opz_tdet' in the document.' occured in Aspose.Words for .NET 4.4.2.0.
For free technical support, please post this error and the file in the Aspose.Words Forums http://www.aspose.com/forums/ShowForum.aspx?ForumID=75. at ?.?.?(Node ?, String ?)
at Aspose.Words.Bookmark.get_BookmarkEnd()
at Aspose.Words.Bookmark.set_Text(String value)

My code is:

Bookmark bookmark = _doc.Range.Bookmarks[nome];

//Find row that contains BookmarkStart
Node start = bookmark.BookmarkStart.ParentNode.ParentNode.ParentNode;

//Find row that contains BookmarkEnd
Node end = bookmark.BookmarkEnd.ParentNode.ParentNode.ParentNode;

//Remove rows between start and end
while (!start.Equals(end))
{
start = start.NextSibling;
start.PreviousSibling.Remove();
}

//Remove bookmark end
bookmark.BookmarkEnd.Remove();
retVal = true;
errors = string.Empty;
}
catch (Exception exc)
{
errors = exc.Message + " " + exc.StackTrace;
retVal = false;
}

Any Ideas?

Thank you

Greatings

Hi

This question is answered in <a href="

Best regards.

Hi, is an another problem!

Please try with this document and this bookmark.

Greatings

Hi

I can’t reproduce this problem on my side. I use Aspose.Words 4.4.3.0 for testing. Please try using the latest version of Aspose.Words.
http://www.aspose.com/Community/Files/51/aspose.words/category1188.aspx

Best regards.