【问题标题】:Formatting table in powerpoint macroPowerPoint 宏中的格式表
【发布时间】:2018-01-30 02:56:14
【问题描述】:

我正在尝试编辑幻灯片中的表格,并且正在使用此代码。有人可以告诉我为什么它不起作用吗?如果不是 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

【问题讨论】:

    标签: vba powerpoint


    【解决方案1】:

    改为这样:

    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
    

    【讨论】:

    • 有没有办法一次性调整所有表格元素的字体大小?
    • 我不知道;表格没有要处理的字体对象,只有组成表格单元格的形状有。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-19
    • 2021-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-27
    • 1970-01-01
    相关资源
    最近更新 更多