Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

Range.ConvertToTable Method

Office 2007
Converts text within a range to a table. Returns the table as a Table object.

Syntax

expression.ConvertToTable(Separator, NumRows, NumColumns, InitialColumnWidth, Format, ApplyBorders, ApplyShading, ApplyFont, ApplyColor, ApplyHeadingRows, ApplyLastRow, ApplyFirstColumn, ApplyLastColumn, AutoFit, AutoFitBehavior, DefaultTableBehavior)

expression   A variable that represents a Range object.

Parameters

NameRequired/OptionalData TypeDescription
SeparatorOptionalVariantSpecifies the character used to separate text into cells. Can be a character or one of the following WdTableFieldSeparator constant. If this argument is omitted, the value of the DefaultTableSeparator property is used.
NumRowsOptionalVariantThe number of rows in the table. If this argument is omitted, Microsoft Word sets the number of rows, based on the contents of the range.
NumColumnsOptionalVariantThe number of columns in the table. If this argument is omitted, Word sets the number of columns, based on the contents of the range.
InitialColumnWidthOptionalVariantThe initial width of each column, in points. If this argument is omitted, Word calculates and adjusts the column width so that the table stretches from margin to margin.
FormatOptionalVariantSpecifies one of the predefined formats listed in the Table AutoFormat dialog box. Can be one of the WdTableFormat constants.
ApplyBordersOptionalVariantTrue to apply the border properties of the specified format.
ApplyShadingOptionalVariantTrue to apply the shading properties of the specified format.
ApplyFontOptionalVariantTrue to apply the font properties of the specified format.
ApplyColorOptionalVariantTrue to apply the color properties of the specified format.
ApplyHeadingRowsOptionalVariantTrue to apply the heading-row properties of the specified format.
ApplyLastRowOptionalVariantTrue to apply the last-row properties of the specified format.
ApplyFirstColumnOptionalVariantTrue to apply the first-column properties of the specified format.
ApplyLastColumnOptionalVariantTrue to apply the last-column properties of the specified format.
AutoFitOptionalVariantTrue to decrease the width of the table columns as much as possible without changing the way text wraps in the cells.
AutoFitBehaviorOptionalVariantSets the AutoFit rules for how Word sizes a table. Can be one of the following WdAutoFitBehavior constant. If DefaultTableBehavior is wdWord8TableBehavior, this argument is ignored.
DefaultTableBehaviorOptionalVariant Sets a value that specifies whether Microsoft Word automatically resizes cells in a table to fit the contents (AutoFit). Can be one of the WdDefaultTableBehavior constant.

Return Value
Table

Example

This example converts the first three paragraphs in the active document to a table.

Visual Basic for Applications
Set aDoc = ActiveDocument
Set myRange = aDoc.Range(Start:=aDoc.Paragraphs(1).Range.Start, _
    End:=aDoc.Paragraphs(3).Range.End)
myRange.ConvertToTable Separator:=wdSeparateByParagraphs



Community Additions

ADD
Show:
© 2015 Microsoft