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 <https://forum.aspose.com/c/words/8>. at ?.?.?(Node ?, String ?)
at Aspose.Words.Bookmark.get_BookmarkEnd()
at Aspose.Words.Bookmark.set_Text(String value)
My code is:
try
{
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