logo
search
VBA & Macro Problems

How to Fix Word VBA Macro Not Changing Black Text Color

Steve KSteve K Oct 16, 2026 870 views

Question details

The user's Word VBA macro fails to find and replace black text with another color.

How to Fix Word VBA Macro Not Changing Black Text 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 you start

Before running the modified macro, ensure you test it on a duplicate copy of your document to prevent unintended changes to your original file.

Solution 1Recommended

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.

1
Open the VBA Editor

Open your Word document and press Alt + F11 to launch the Visual Basic for Applications editor.

2
Locate the Macro

Find your color-replacement macro in the Project Explorer panel and open the code module.

3
Create a Color Value Array

Set up an array in your code containing the values for RGB Black (0), Theme Black (-587137025), and Automatic (-16777216 or wdColorAutomatic).

4
Implement a For-Next Loop

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.

5
Run the Updated Script

Set the replacement parameter to your desired output color, such as RGB(83, 129, 53), and execute the macro.

Update VBA Macro to Include Theme and Automatic Black
VBA Color Constants: wdColorAutomatic is a built-in constant equal to -16777216. Using the constant makes your code easier to read and maintain.
WPS Office Writer VBA Support

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. 1. Download WPS Office: Download and install the latest version of WPS Office.
  2. 2. Open Your Document: Launch WPS Writer and open the document you wish to edit.
  3. 3. Access Macro Tools: Navigate to the Developer tab to access the Macro and VBA Editor.
  4. 4. Run the Script: Paste your modified color-replacement script into the editor and run it directly.
Highly compatible with Microsoft Word VBA macros and formatsLightweight software with incredibly fast execution speedFree built-in features for comprehensive document processing
QA img-9

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.