Export (0) Print
Expand All

Table.AutoFormat Method

Office 2007
Applies a predefined look to a table.

Syntax

expression.AutoFormat(Format, ApplyBorders, ApplyShading, ApplyFont, ApplyColor, ApplyHeadingRows, ApplyLastRow, ApplyFirstColumn, ApplyLastColumn, AutoFit)

expression   Required. A variable that represents a Table object.

Parameters

NameRequired/OptionalData TypeDescription
FormatOptionalVariantThe format to apply. This parameter can be a WdTableFormat constant, a WdTableFormatApply constant, or a TableStyle object.
ApplyBordersOptionalVariantTrue to apply the border properties of the specified format. The default value is True.
ApplyShadingOptionalVariantTrue to apply the shading properties of the specified format. The default value is True.
ApplyFontOptionalVariantTrue to apply the font properties of the specified format. The default value is True.
ApplyColorOptionalVariantTrue to apply the color properties of the specified format. The default value is True.
ApplyHeadingRowsOptionalVariantTrue to apply the heading-row properties of the specified format. The default value is True.
ApplyLastRowOptionalVariantTrue to apply the last-row properties of the specified format. The default value is False.
ApplyFirstColumnOptionalVariantTrue to apply the first-column properties of the specified format. The default value is True.
ApplyLastColumnOptionalVariantTrue to apply the last-column properties of the specified format. The default value is False.
AutoFitOptionalVariantTrue to decrease the width of the table columns as much as possible without changing the way text wraps in the cells. The default value is True.

Remarks

The arguments for this method correspond to the options in the Table AutoFormat dialog box.

Example

This example creates a 5x5 table in a new document and applies all the properties of the Colorful 2 format to the table.

Visual Basic for Applications
Set newDoc = Documents.Add
Set myTable = newDoc.Tables.Add(Range:=Selection.Range, _
    NumRows:=5, NumColumns:=5)
myTable.AutoFormat Format:=wdTableFormatColorful2

This example applies all the properties of the Classic 2 format to the table in which the insertion point is currently located. If the insertion point isn't in a table, a message box is displayed.

Visual Basic for Applications
Selection.Collapse Direction:=wdCollapseStart
If Selection.Information(wdWithInTable) = True Then
    Selection.Tables(1).AutoFormat Format:=wdTableFormatClassic2
Else
    MsgBox "The insertion point is not in a table."
End If



Community Additions

ADD
Show:
© 2014 Microsoft