TopLevelTables 属性 (Word)Selection.TopLevelTables property (Word)

返回一个**tables** 集合, 该集合代表当前选定内容最外部嵌套层上的表格。Returns a Tables collection that represents the tables at the outermost nesting level in the current selection. 此为只读属性。Read-only.


expressionexpression. TopLevelTables

_表达式_一个代表**Selection** 对象的变量。expression A variable that represents a Selection object.


此方法返回一个集合,该集合仅包含当前选定区域的上下文中最外部嵌套层上的那些表格。This method returns a collection containing only those tables at the outermost nesting level within the context of the current selection. 这些表格可能不在整套嵌套表格的最外部嵌套层中。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.


以下示例新建一个文档,创建一个三层嵌套表格,并在每张表格的第一个单元格中填入该表格所在的嵌套层数。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.

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

另请参阅See also

Selection 对象Selection Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.