VBA word - 为表格设置字体样式

VBA word - set font styling to tables

我正在尝试只为第二个 Word 页面之后的表格设置字体样式。 到目前为止我得到了:

Sub defaultFontStyling()

    If Selection.Information(wdWithInTable) = True Then
        
        Range.Font.Name = "Calibri"
        Range.Font.Size = 11
        
    End If

End Sub

我在第一页上没有任何表格,但它仍然改变了那里的字体样式(在整个文档中)。

有人知道如何解决吗?

试试这个:

Sub defaultFontStyling()
    Dim table As table
    For Each table In ActiveDocument.Tables
        If table.Range.Information(wdActiveEndAdjustedPageNumber) > 1 Then
            With table.Range.Font
                .Name = "Calibri"
                .Size = 11
            End With
        End If
    Next
End Sub