我有一个包含大量表格的100幻灯片PowerPoint演示文稿,并希望使用VBA代码来更改每个表格上的标题颜色。模板的默认颜色输入具有以下格式的表格,标题颜色为RGB(79,129,189):
我需要将标题颜色更改为更深的蓝色RGB(0,56,104)。见下面的例子:
以前使用以下代码更改演示文稿中的形状颜色,所以想知道这个新任务是否有类似的方法。提前感谢您的帮助。
`Sub ChangeShapeColor()
Dim shp As Shape
Dim sld As Slide
For Each shp In ActivePresentation.Slides
' Look at each shape on each slide:
For Each shp In sld.Shapes
If shp.Fill.ForeColor.RGB = RGB(79, 129, 189) Then
shp.Fill.ForeColor.RGB = RGB(0, 56, 104)
End If
Next shp
Next sld
结束Sub`
答案 0 :(得分:0)
这会将演示文稿中每个表格第一行的颜色更改为红色。您可以根据需要调整颜色,如果您只想更改标题为特定颜色的表格,则添加If / Then。
Sub RecolorTableHeader()
Dim oSl As Slide
Dim oSh As Shape
Dim x As Long
For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
If oSh.HasTable Then
With oSh.Table
For x = 1 To .Columns.Count
.Cell(1, x).Shape.Fill.ForeColor.RGB = RGB(255, 0, 0)
Next
End With
End If
Next
Next
End Sub