reference to nested tables

K

k2sarah

i have created in word a nested table. outside table is 2x2, and in cell (row
2 column 2) i have a nested table which is 3x3. i am having trouble refering
to the nested table via vba and make changes. can anyone provide the code
whereby, i can make a reference to the nested table and modify cells in the
nested table?
 
J

Jay Freedman

i have created in word a nested table. outside table is 2x2, and in cell (row
2 column 2) i have a nested table which is 3x3. i am having trouble refering
to the nested table via vba and make changes. can anyone provide the code
whereby, i can make a reference to the nested table and modify cells in the
nested table?

This sample shows how to drill down through the structure. Once you
see how the parts are related, you can start taking shortcuts instead
of explicitly assigning each part along the way.

Sub Test()
Dim outerTable As Table, innerTable As Table
Dim outerCell As Cell, innerCell As Cell


Set outerTable = ActiveDocument.Tables(1)
Set outerCell = outerTable.Cell(2, 2)

Set innerTable = outerCell.Tables(1)
Set innerCell = innerTable.Cell(3, 3)

innerCell.Range.Text = "Cell(3,3)"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top