Tables.Add Method
Word Developer Reference |
Returns a Table object that represents a new, blank table added to a document.
Syntax
expression.Add(Range, NumRows, NumColumns, DefaultTableBehavior, AutoFitBehavior)
expression Required. A variable that represents a Tables collection.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
Range | Required | Range object | The range where you want the table to appear. The table replaces the range, if the range isn't collapsed. |
NumRows | Required | Long | The number of rows you want to include in the table. |
NumColumns | Required | Long | The number of columns you want to include in the table. |
DefaultTableBehavior | Optional | Variant | Sets a value that specifies whether Microsoft Word automatically resizes cells in tables to fit the cells’ contents (AutoFit). Can be either of the following constants: wdWord8TableBehavior (AutoFit disabled) or wdWord9TableBehavior (AutoFit enabled). The default constant is wdWord8TableBehavior. |
AutoFitBehavior | Optional | Variant | Sets the AutoFit rules for how Word sizes tables. Can be one of the WdAutoFitBehavior constants. |
Return Value
Table
Example
This example adds a blank table with three rows and four columns at the beginning of the active document.
Visual Basic for Applications |
---|
|
This example adds a new, blank table with six rows and ten columns at the end of the active document
Visual Basic for Applications |
---|
|
This example adds a table with three rows and five columns to a new document and then inserts data into each cell in the table.
Visual Basic for Applications |
---|
|
See Also