AutoFormat Method Example

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

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.

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

This example automatically formats the selection.

Selection.Range.AutoFormat