Set a Custom Hexadecimal Text Color in PowerPoint VBA
Question details
Set a PowerPoint text box font to the custom color #ED6C2A using VBA.

- Product
- Microsoft PowerPoint
- Device & OS
- not provided
- Scenario
- A VBA macro creates a text box and needs to apply a specific RGB color to its text.
- Observed behavior
- Assigning the standard RGB hexadecimal value directly produces a color with the red and blue components reversed.
Identify the text box or the shape variable used by your macro. If you plan to test the examples below, select the text box on the slide and open the VBA editor with Alt+F11.
Set the Text Color With the VBA RGB Function
Use RGB to specify the red, green, and blue components in their familiar order.
In PowerPoint, select the text box, press Alt+F11, and choose Insert > Module.
Enter this macro in the module: Sub SetTextColor() ActiveWindow.Selection.ShapeRange(1).TextFrame.TextRange.Font.Color.RGB = RGB(237, 108, 42) End Sub
Return to the slide, confirm the text box is selected, and run SetTextColor from Developer > Macros.

Set the Text Color With a BGR Hexadecimal Value
Use this option if you prefer to assign a hexadecimal literal directly in VBA.
Edit Presentation Colors With WPS Presentation
WPS Office is a free, lightweight alternative with a familiar interface for editing presentations and their text colors. It supports common PowerPoint formats for easier migration, although it does not fix PowerPoint VBA behavior and macro compatibility may vary.

Frequently Asked Questions
Why does &HED6C2A produce the wrong color in PowerPoint VBA?
The standard hex code #ED6C2A lists red, green, and blue in RGB order, but a VBA color literal uses BGR byte order. Use &H2A6CED or RGB(237, 108, 42) instead.
How do I apply the color to a text box created by my macro?
Use the shape variable from your macro, followed by .TextFrame.TextRange.Font.Color.RGB = RGB(237, 108, 42). This sets the text color rather than the box fill.
How do I set the text box fill instead of the font color?
Use the shape's Fill.ForeColor.RGB property, for example: myShape.Fill.ForeColor.RGB = RGB(237, 108, 42). Replace myShape with your shape variable.
Where can I run the example macro?
Select the text box on the slide, then choose Developer > Macros, select the macro name, and click Run. Enable macros only for presentations you trust.




