使用預先定義之表格格式的特性來更新表格。
語法
expression. UpdateAutoFormat
需要 expression。 代表 'Table' 物件的變數。
註解
範例如何此方法的功能,如果您套用 自動格式設定 的表格格式,然後插入列和欄、 表格可能不會再為符合預先定義的外觀。 UpdateAutoFormat 還原格式。
範例
這則範例會建立一個表格、將預先定義的格式套用至此表格、加入一列,然後重新套用預先定義的格式。
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
這則範例會將預先定義的格式還原成包含插入點的表格。
If Selection.Information(wdWithInTable) = True Then
Selection.Tables(1).UpdateAutoFormat
Else
MsgBox "The insertion point is not in a table."
End If
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。