0
votes

I have a 100 slide PowerPoint presentation with tons of tables and would like to use VBA code to change the color of the headers on each table. The default color from the template inputs the table with the below format with the header color as RGB (79, 129, 189): enter image description here

I need to change the header colors to a darker blue RGB (0, 56, 104). See example below: enter image description here

The have used the below code before to change shape colors in a presentation, so was wondering if there is a similar method for this new task. Thanks in advance for any help.

`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

End Sub`

1

1 Answers

1
votes

This will change the color of the first row of each table in the presentation to red. You can adapt it to the color you want and add the If/Then if you only want to change tables whose header is a specific color.

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