Skip to content

Latest commit

 

History

History
65 lines (44 loc) · 2.01 KB

Word.Range.TopLevelTables.md

File metadata and controls

65 lines (44 loc) · 2.01 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Range.TopLevelTables property (Word)
vbawd10.chm157155652
vbawd10.chm157155652
Word.Range.TopLevelTables
43cd13b8-f779-69cd-ee60-d4ba734008f0
06/08/2017
medium

Range.TopLevelTables property (Word)

Returns a Tables collection that represents the tables at the outermost nesting level in the current range. Read-only.

Syntax

expression. TopLevelTables

expression A variable that represents a Range object.

Remarks

This method returns a collection containing only those tables at the outermost nesting level within the context of the current range. These tables may not be at the outermost nesting level within the entire set of nested tables.

For information about returning a single member of a collection, see Returning an object from a collection.

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. The example selects the second column of the second-level table and then selects the first of the top-level tables in this selection. The innermost table is selected, even though it isn't a top-level table within the context of the entire set of nested tables.

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 
 .Columns(2).Select 
 Selection.Range.TopLevelTables(1).Select 
 End With 
End With

See also

Range Object

[!includeSupport and feedback]