Table.UpdateAutoFormat Method

Word Developer Reference

Updates the table with the characteristics of a predefined table format.

Syntax

expression.UpdateAutoFormat

expression   Required. A variable that represents a Table object.

Remarks

As an example of how this method functions, if you apply a table format with AutoFormat and then insert rows and columns, the table may no longer match the predefined look. UpdateAutoFormat restores the format.

Example

This example creates a table, applies a predefined format to it, adds a row, and then reapplies the predefined format.

Visual Basic for Applications
  Dim docNew As Document
Dim tableNew As Table

Set docNew = Documents.Add Set tableNew = docNew.Tables.Add(Selection.Range, 5, 5)

With tableNew .AutoFormat Format:=wdTableFormatColumns1 .Rows.Add BeforeRow:=tableNew.Rows(1) End With MsgBox "Click OK to reapply autoformatting." tableNew.UpdateAutoFormat

This example restores the predefined format to the table that contains the insertion point.

Visual Basic for Applications
  If Selection.Information(wdWithInTable) = True Then
    Selection.Tables(1).UpdateAutoFormat
Else
    MsgBox "The insertion point is not in a table."
End If

See Also