Free Support Forum -

Finding a table

Is there a better way other than by table index to find a table in a word document? Ideally, I would like to set a bookmark and then get the next table after that bookmark.

This is what I am doing now:

Dim parentTable = DirectCast(WordDocument.GetChild(NodeType.Table, 6, True), Aspose.Words.Tables.Table)

Hi Russ,

Thanks for your inquiry. You are getting the Table node correctly. You may also get all Table nodes by Document.GetChildNodes method as shown in following code snippet.

Document doc = new
Document(MyDir + “in.docx”);<o:p></o:p>

foreach (Table table in doc.GetChildNodes(NodeType.Table, true))



I was actually able to get it this way:

bk = WordDocument.Range.Bookmarks("ItemTable")

parentTable = DirectCast(bk.BookMarkEnd.GetAncestor(NodeType.Table), Aspose.Words.Tables.Table)

Hi Russ,

Thanks for your feedback. It is nice to hear from you that you have solved your problem. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.