PDA

View Full Version : Convert Text Color in PowerPoint



BobbyB123
12-17-2015, 05:27 PM
Does anyone have a good macro code for powerpoint that converts one font color to another? For example, I would like to convert all the text in orange to black.

John Wilson
12-18-2015, 01:34 AM
There are a few "IFS" here.

If all the text is in placeholders or shapes but not tables or charts and not on the master.
If by "Orange" you mean the standard Orange (RGB(255,192,0)

Then try this:



Sub switchOrange()
Dim oshp As Shape
Dim osld As Slide
Dim lngRunCount As Long
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.HasTextFrame Then
For lngRunCount = 1 To oshp.TextFrame.TextRange.Runs.Count
If oshp.TextFrame.TextRange.Runs(lngRunCount).Font.Color.RGB = RGB(255, 192, 0) Then
oshp.TextFrame.TextRange.Runs(lngRunCount).Font.Color.RGB = vbBlack
End If
Next lngRunCount
End If
Next oshp
Next osld
End Sub

BobbyB123
12-18-2015, 07:12 AM
It worked. Thank you very much!


There are a few "IFS" here.

If all the text is in placeholders or shapes but not tables or charts and not on the master.
If by "Orange" you mean the standard Orange (RGB(255,192,0)

Then try this:



Sub switchOrange()
Dim oshp As Shape
Dim osld As Slide
Dim lngRunCount As Long
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.HasTextFrame Then
For lngRunCount = 1 To oshp.TextFrame.TextRange.Runs.Count
If oshp.TextFrame.TextRange.Runs(lngRunCount).Font.Color.RGB = RGB(255, 192, 0) Then
oshp.TextFrame.TextRange.Runs(lngRunCount).Font.Color.RGB = vbBlack
End If
Next lngRunCount
End If
Next oshp
Next osld
End Sub