Dim tblParent As Table, tblSelection As Table
Dim rng As Range
' with help of the used table.style name i checked if the Child table is
selected if so:
Set tblSelection = Selection.Range.Tables(1)
Set rng = tblSelection.Cell(1, 1).Range
rng.MoveEnd Unit:=wdCell, Count:=-1
Set tblParent = rng.Tables(1)
But I prefer to address the ParentTable direct. Do you have an idea how?
Thanks,
Ward
Dim tblParent As Table
Dim nIndex As Long
If Selection.Tables(1).NestingLevel > 1 Then 'nested
'Find the index of the first character before the nested table
'that character is in the parent table
nIndex = Selection.Tables(1).Range.Start
Set tblParent = ActiveDocument.Range.Tables(ActiveDocument.Range(0,
nIndex).Tables.Count)
End If
I have tested a little. If you have more nesting levels, the code still
selects the first-level table. I am on my way out just now, so I am not able
to experiment further now. Please post back if needed and I will take a look
later.
--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
Thanks for your answer. I understand that there is no direct adressing, with
a Parent- or Child- methode. Your solution with NestingLevel is more robust
than mine. I will use that. And your methode for "Set Parent" is far better
than mine.
Thanks for helping me futher.
Ward