table nesting levels

J

Jezebel

I have some code that carries out an operation on the table containing the
current selection. Works fine on a simple table. If the selection is in a
nested table, I need to work on the parent table. I can check if the
selection is in a nested table (Table.NestingLevel > 1) -- but how can I get
a reference from there to the parent table? From my reading of the
documentation, I should be able to use

Selection.TopLevelTables(1)

But applying my code to this reference affects the rows of the nested table
and the rows of the parent table *following* the nested table. Anyone have
any experience with this?
 
C

Cindy M -WordMVP-

Hi Jezebel,

Re-read the text for the Help example again, it basically says this function
doesn't look "outwards", as I understand it.

What does seem to work is something like

Dim rng As Word.Range

Set rng = Selection.Range
Debug.Print rng.Tables(1).NestingLevel
Do While rng.Tables(1).NestingLevel > 1
Set rng = rng.Tables(1).Range
rng.Collapse wdCollapseEnd
Loop
Debug.Print rng.Tables(1).NestingLevel
rng.Tables(1).Select

I have some code that carries out an operation on the table containing the
current selection. Works fine on a simple table. If the selection is in a
nested table, I need to work on the parent table. I can check if the
selection is in a nested table (Table.NestingLevel > 1) -- but how can I get
a reference from there to the parent table? From my reading of the
documentation, I should be able to use

Selection.TopLevelTables(1)

But applying my code to this reference affects the rows of the nested table
and the rows of the parent table *following* the nested table. Anyone have
any experience with this?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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