Trying to loop through all slides in a powerpoint and change whatever text tables there are in each slide to a blue color and black text.
getting a compile error here on the .font.color
line
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
any ideas?
oSdl
in oSdl.Shapes
is a typo, it should be osld
(Dim osld As Slide
). Using Option Explicit
to avoid this kind of problem..TextFrame.TextRange.Font.Color
to update font coloroShp.HasTable
, otherwise oShp.HasTable
may raise error.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 '**
If oShp.HasTable Then '**
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
End With
Next
Next
End With
End Sub