How to Fix Word VBA Macro Not Changing Black Text Color
Question details
The user's Word VBA macro fails to find and replace black text with another color.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Running a VBA macro to find black text and replace it with a specific RGB color.
- Observed behavior
- The macro does not detect the black text because the text is formatted as Theme Black or Automatic rather than standard RGB black.
Before running the modified macro, ensure you test it on a duplicate copy of your document to prevent unintended changes to your original file.
Update VBA Macro to Include Theme and Automatic Black
Modify your VBA script to loop through Theme Black and Automatic black alongside standard RGB black.
Word often uses 'Automatic' or 'Theme Black' as default text colors rather than absolute RGB(0, 0, 0). These colors have specific negative VBA values because they adapt to document themes or backgrounds.
Open your Word document and press Alt + F11 to launch the Visual Basic for Applications editor.
Find your color-replacement macro in the Project Explorer panel and open the code module.
Set up an array in your code containing the values for RGB Black (0), Theme Black (-587137025), and Automatic (-16777216 or wdColorAutomatic).
Write a For-Next loop to iterate through these three color values. Leave the .Text value intentionally blank to focus on replacing the color format within the selected text.
Set the replacement parameter to your desired output color, such as RGB(83, 129, 53), and execute the macro.

Convert Text to Standard RGB Black Manually
Manually change the target text to a true RGB black so your existing macro can detect it without modifications.
Run and Edit VBA Macros Seamlessly in WPS Writer
WPS Office provides robust support for VBA macros, allowing you to easily automate repetitive formatting tasks and handle complex document styling.
- 1. Download WPS Office: Download and install the latest version of WPS Office.
- 2. Open Your Document: Launch WPS Writer and open the document you wish to edit.
- 3. Access Macro Tools: Navigate to the Developer tab to access the Macro and VBA Editor.
- 4. Run the Script: Paste your modified color-replacement script into the editor and run it directly.

Frequently Asked Questions
Why does my macro miss certain black text?
Your document likely uses 'Theme Black' or 'Automatic' settings instead of absolute RGB(0,0,0). These dynamic colors have different internal VBA values that a standard RGB search will ignore.
What is the VBA value for Automatic black?
Automatic black is represented by the built-in constant wdColorAutomatic, which carries a numeric value of -16777216.
How do I test my color-replacement macro safely?
Always run macro scripts on a duplicate copy of your document or within a defined text selection to ensure it replaces colors correctly without permanently altering unintended content.
Does finding and replacing colors require text in the .Text property?
No. You can intentionally leave the .Text property blank if your goal is solely to find and replace the color format of the currently selected text.




