尝试将PPT幻灯片中的所有文本表格更改为文本颜色和单元格填充颜色?

问题描述 投票:0回答:2

尝试循环浏览 Powerpoint 中的所有幻灯片,并将每张幻灯片中的任何文本表更改为蓝色和黑色文本。

.font.color 
行出现编译错误

Sub TableAllBlueandBlack()

Dim lRow As Integer
Dim lCol As Integer
Dim oTbl As Table
Dim osld As Slide
Dim oShp As Shape

With ActivePresentation
    For Each osld In .Slides
        For Each oShp In oSdl.Shapes
            Set oTbl = oShp.Table
                With oTbl
                    For lRow = 1 To .Rows.Count
                            For lCol = 1 To .Columns.Count
                                With .Cell(lRow, lCol).Shape
                                    .Fill.ForeColor.RGB = RGB(211, 225, 241) 
                                    .Font.Color = RGB(0, 0, 0)
                                End With
                            Next
                    Next
                End With
            Next
        Next
End With
End Sub

有什么想法吗?

vba powerpoint
2个回答
0
投票

Shape
没有
Font
属性。你可以使用:

.TextFrame.TextRange.Font.Color = RGB(0, 0, 0) 


0
投票
  • oSdl
    中的
    oSdl.Shapes
    是错字,应该是
    oSld
    。使用
    Option Explicit
    可以避免类似的问题。
  • 使用
    .TextFrame.TextRange.Font.Color
    更新字体颜色
Option Explicit

Sub TableAllBlueandBlack()
    Dim lRow As Integer
    Dim lCol As Integer
    Dim oTbl As Table
    Dim oSld As Slide
    Dim oShp As Shape
    With ActivePresentation
        For Each oSld In .Slides
            For Each oShp In oSld.Shapes '**
                Set oTbl = oShp.Table
                With oTbl
                    For lRow = 1 To .Rows.Count
                        For lCol = 1 To .Columns.Count
                            With .Cell(lRow, lCol).Shape
                                .Fill.ForeColor.RGB = RGB(211, 225, 241)
                                .TextFrame.TextRange.Font.Color = RGB(0, 0, 0) '**
                            End With
                        Next
                    Next
                End With
            Next
        Next
    End With
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.