NestingLevel Property Example

This example creates a new document, creates a nested table with three levels, and then fills the first cell of each table with its nesting level.

Documents.Add
ActiveDocument.Tables.Add Selection.Range, _
    3, 3, wdWord9TableBehavior, wdAutoFitContent
With ActiveDocument.Tables(1).Range
    .Copy
    .Cells(1).Range.Text = .Cells(1).NestingLevel
    .Cells(5).Range.PasteAsNestedTable
    With .Cells(5).Tables(1).Range
        .Cells(1).Range.Text = .Cells(1).NestingLevel
        .Cells(5).Range.PasteAsNestedTable
        With .Cells(5).Tables(1).Range
            .Cells(1).Range.Text = _
                .Cells(1).NestingLevel
        End With
    End With
End With