在 powerpoint 宏中格式化 table

Formatting table in powerpoint macro

我正在尝试编辑幻灯片中的 table,我正在使用此代码。有人可以告诉我为什么它不起作用吗?如果不是 s.Shapes.Table 我有 s.Shapes.Range 例如它工作正常。

Sub format()
Dim s As Slide
For Each s In ActivePresentation.Slides
With s.Shapes.Table
.TextFrame.TextRange.Font.Name = "Arial"
.TextFrame.TextRange.Font.Size = 30
End With
Next s
End Sub

像这样:

Sub format()

Dim s As Slide
Dim oSh As Shape
Dim oTbl As Table
Dim lRow As Long
Dim lCol As Long

For Each s In ActivePresentation.Slides
' If you choose Debug | Compile, this next line fails
' There's no such property as .Table
' With s.Shapes.Table
    For Each oSh In s.Shapes
        If oSh.HasTable Then
            Set oTbl = oSh.Table
            For lRow = 1 To oTbl.Rows.Count
                For lCol = 1 To oTbl.Columns.Count
                    With oTbl.Cell(lRow, lCol).Shape.TextFrame.TextRange
                        .Font.Name = "Arial"
                        .Font.Size = 30
                    End With
                Next
            Next
        End If
    Next    ' Shape
Next s

End Sub