尝试循环浏览 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
有什么想法吗?
Shape
没有 Font
属性。你可以使用:
.TextFrame.TextRange.Font.Color = RGB(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