Naxos
Naxos

Reputation: 51

VBA Powerpoint - How to highlight selected text

I would like to highlight the selected text into a colour but this is not working. Could you help me with that ?

Sub ShadingLtYellow()
    ActiveWindow.Selection.TextRange.HighlightColor.RGB = RGB(255, 255, 175)
End Sub

Also can I trigger the macro using the a keyboard shortcut such as application onkeys on Excel ?

This would be great

Upvotes: 2

Views: 2412

Answers (1)

John Korchok
John Korchok

Reputation: 4913

TextRange is for backward compatibility with older versions of PowerPoint. With current versions (2010 and later), use the Textrange2 object instead, it has Highlight:

ActiveWindow.Selection.TextRange2.Font.Highlight.RGB = RGB(255, 255, 175)

Upvotes: 6

Related Questions