我有一个 PPT,里面有 100 张幻灯片和一些文本表格。尝试将这些表格中的颜色从绿色更改为蓝色。
到
在具有我的 RGB 颜色 # 的行上出现编译错误。有什么想法吗?
Sub TableAllBlack()
Dim lRaw 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) 'Add your color here
End With
Next
Next
End With
Next
Next
End With
End Sub
@Ted Williams 说得对。检查形状,如果是桌子,则更改颜色。
Sub TableAllRED()
Dim i, j, k As Integer
With ActivePresentation
nslides = .Slides.Count
For i = 1 To nslides
j = .Slides(i).Shapes.Count
For k = 1 To j
.Slides(i).Shapes(k).Select
If ActiveWindow.Selection.ShapeRange.HasTable = msoTrue Then
ActiveWindow.Selection.ShapeRange(1).Fill.ForeColor.RGB = RGB(255, 0, 0)
End If
Next k
Next i
End With
End Sub