VBA & Macro Problems

Set a Custom Hexadecimal Text Color in PowerPoint VBA

Maira MehtabMaira Mehtab Nov 20, 2026 869 views

Question details

Set a PowerPoint text box font to the custom color #ED6C2A using VBA.

Set a Custom Hexadecimal Text Color in PowerPoint 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.
Before you start

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.

Solution 1Recommended

Set the Text Color With the VBA RGB Function

Use RGB to specify the red, green, and blue components in their familiar order.

1
Open the VBA editor

In PowerPoint, select the text box, press Alt+F11, and choose Insert > Module.

2
Add the color macro

Enter this macro in the module: Sub SetTextColor() ActiveWindow.Selection.ShapeRange(1).TextFrame.TextRange.Font.Color.RGB = RGB(237, 108, 42) End Sub

3
Run the macro

Return to the slide, confirm the text box is selected, and run SetTextColor from Developer > Macros.

Set the Text Color With the VBA RGB Function
Using an existing shape variable: If your macro already creates a text box, replace ActiveWindow.Selection.ShapeRange(1) with that shape variable.
Free Microsoft Office alternative

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.

Adjust presentation text colors through a familiar interfaceOpen and edit Microsoft PowerPoint PPT and PPTX filesWork in a lightweight office suite with free featuresMove between familiar document, spreadsheet, and presentation tools
microsoft office alternative - wps office

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.