Set a Custom Font Color in Word 2010 VBA
Question details
The user needs to set a custom font color in Word 2010 using VBA.

- Product
- Microsoft Word 2010
- Device & OS
- not provided
- Scenario
- Applying a named theme color to selected text through a VBA statement.
- Observed behavior
- Using a color name such as Orange, Accent 6, Darker 25% in the statement produces an Expected end of statement error.
Select the text you want to color and identify the color's red, green, and blue values. In Word, you can inspect a color through Home > Font Color > More Colors > Custom.
Set the selected font color with RGB in Word VBA
Use numeric RGB values instead of a color name to avoid the VBA syntax error.
The RGB function takes red, green, and blue values from 0 to 255. It applies a fixed color, so it will not automatically change with the document theme.
In Word 2010, press Alt+F11, then choose Insert > Module.
In the module, enter: Sub SetFontColor() Selection.Font.Color = RGB(0, 0, 255) End Sub. Replace 0, 0, 255 with the RGB values for your desired color; the example applies blue.
Return to the document and select the text. Press Alt+F8, select SetFontColor, and click Run.

Apply Custom Font Colors in WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility, making it easy to move documents and apply font colors in WPS Writer. It does not fix Word's VBA syntax error.

Frequently Asked Questions
Why does a named theme color cause a VBA error?
Word VBA does not accept a label such as Orange, Accent 6, Darker 25% as a color value in that statement. Set Selection.Font.Color with RGB(red, green, blue) instead.
How do I find the RGB values of a font color?
Select text with the color, then open Home > Font Color > More Colors > Custom and check the red, green, and blue values.
Will an RGB font color change when I switch themes?
No. Selection.Font.Color = RGB(...) applies a fixed color rather than a theme-linked color.
How can I keep the macro in my document?
Use File > Save As and choose Word Macro-Enabled Document (*.docm). To run it later, press Alt+F8 and select the macro.




