如何在PPT中改变table header颜色VBA
How to change table header color in PPT VBA
我有一个包含大量 table 的 100 张幻灯片的 PowerPoint 演示文稿,我想使用 VBA 代码更改每个 table 上 header 的颜色].模板中的默认颜色输入 table,格式如下,header 颜色为 RGB (79, 129, 189):
我需要将 header 颜色更改为深蓝色 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
结束子`
这会将演示文稿中每个 table 第一行的颜色更改为红色。如果您只想更改 header 是特定颜色的 table,您可以将其调整为您想要的颜色并添加 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
我有一个包含大量 table 的 100 张幻灯片的 PowerPoint 演示文稿,我想使用 VBA 代码更改每个 table 上 header 的颜色].模板中的默认颜色输入 table,格式如下,header 颜色为 RGB (79, 129, 189):
我需要将 header 颜色更改为深蓝色 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
结束子`
这会将演示文稿中每个 table 第一行的颜色更改为红色。如果您只想更改 header 是特定颜色的 table,您可以将其调整为您想要的颜色并添加 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