Share via


Tables Collection Object

Multiple objects
Tables
Table
Multiple objects

A collection of Table objects that represent the tables in a selection, range, or document.

Using the Tables Collection

Use the Tables property to return the Tables collection. The following example applies a border around each of the tables in the active document.

For Each aTable In ActiveDocument.Tables
    aTable.Borders.OutsideLineStyle = wdLineStyleSingle
    aTable.Borders.OutsideLineWidth = wdLineWidth025pt
    aTable.Borders.InsideLineStyle = wdLineStyleNone
Next aTable

Use the Add method to add a table at the specified range. The following example adds a 3x4 table at the beginning of the active document.

Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.Tables.Add Range:=myRange, NumRows:=3, NumColumns:=4

Use Tables(index), where index is the index number, to return a single Table object. The index number represents the position of the table in the selection, range, or document. The following example converts the first table in the active document to text.

ActiveDocument.Tables(1).ConvertToText Separator:=wdSeparateByTabs

Remarks

The Count property for this collection in a document returns the number of items in the main story only. To count items in other stories use the collection with the Range object.

Properties | Application Property | Count Property | Creator Property | NestingLevel Property | Parent Property

Methods | Add Method | Item Method

Parent Objects | Cell | Document | Range | Selection | Table

Child Objects | Borders | Columns | Range | Rows | Shading | Tables

See Also | Error Accessing a Table Row or Column | Working with Tables