How to determine table via bookmark?


#1

I’m in the process of evaluating Aspose.Word to replace our Word automation code. One of the tasks I need to do is replace all bookmarks will some text. This has been very easy and straight forward.

However, I’m having difficulty when the bookmark is located in a table. When a bookmark is in a table, the code needs to delete the contents of the entire table and insert to text in one or more of the table cells.

The issue I’m having is determining the table I’m in based on finding the bookmark. I can easily replace the bookmark text but I can’t seem to determine the table the bookmark is located in.

Does anyone out there have any suggestions on determining the table based on a bookmark?

Any help is greatly appreciated.

Thanks,
Scott


#2

This task can be accomplished using Node.GetAncestor(Type) method. For example:

bookmark.BookmarkStart.GetAncestor(Aspose.Words.Table);

Hope this helps. Please let me know if you have any other questions regarding Aspose.Words. I will be glad to assist you with whatever I can.

Best regards,