Free Support Forum - aspose.com

Problem with bookmark text deletion

I am trying to delete a bookmark's content. My code works fine for some of them, however it fails form some others (a Word table in this case). A sample of my code as well as the error message is shown bellow. How do I ensure the grand parent is the same?

Exception Details: System.ArgumentException: Start and end node should have the same grand parent.

Source Error:

Line 105:				if(EvaluateXPath(test))
Line 106:				{	
Line 107:					document.Range.Bookmarks[bookmark].Text = "";
Line 108:

Please attach one of the problem documents here. It will help us to reproduce the error.

Here goes a sample of the document with one bookmark ("Delete").

Although bookmark start and end look like they are in the same cell in MS Word, actually the bookmark starts in the preceding cell (5.2 (a)) and ends in the start of the following cell (5.2 (ii)).

Text manipulation of bookmarks spanning several cells is not yet supported in Aspose.Words.

This problem is logged to our defect base as Issue #911. We will deal with it eventually.

As a workaround, try to bookmark text inside cell instead of marking cell as a whole. I am attaching the document where new bookmark "Delete1" was added which does not cause any exception when setting its text to "".