Macro for replacing colors in Word 97 (VB)
Thread poster: Cecilia Falk

Cecilia Falk  Identity Verified
Local time: 22:31
English to Swedish
Jan 21, 2005

I often use colors when manipulating my translations in order to mark out
various things (text not to be spellchecked, etc) so I often have to search
and replace colors.
In order to skip all the steps in the Search and Replace dialog evertime I
want to do this I am now trying to write a macro which is basically a
dialogbox with two sets of option buttons for all the colors and what I
would like to happen is that you for example check the option button for
"Blue" in the first set and the the option button for "Green" in the second
set and then click OK in order to replace all Blue text with Green.
I am only an amateur when it comes to macros and I am stuck at what code to
write for the Command button "OK" to make this happen. Does anybody have a
quick tips, an URL or something. I have been reading my hanbbok for VBA,
but can't find anything there or in the help that I understand;-)
Or maybe there is an even easier way to accomplish this?

Best regards,

[Edited at 2005-01-21 00:19]


Jaroslaw Michalak  Identity Verified
Local time: 22:31
Member (2004)
English to Polish
Let's try this... Jan 21, 2005

I didn't test it yet, as it would requiring preparing the dialog form etc., but the following set of instructions should work:

With ActiveDocument.Content.Find
.Font.ColorIndex = Color1
.Text = ""
With .Replacement
.Font.ColorIndex = Color2
.Text = ""
End With
.Execute Format:=True, Replace:=wdReplaceAll
End With

Color1 and Color2 are the values set by the appropriate dialog box items. The instruction replaces the colors only in the main text (story). For headers, footers etc. this would require a loop.

This is for Word 2000, but I think it should work the same as for Word 97.

Some time later I might write the whole procedure, but I guess you would prefer finishing it yourself, it's much more fun! And the knowledge you get will help you more useful macros.

[Edited at 2005-01-21 02:24]


Cecilia Falk  Identity Verified
Local time: 22:31
English to Swedish
Thank you! Jan 24, 2005

I recieved some other suggestions also from other sources, so my next step will be to try them all to see which one I get to work
Thanks again, it is great to be able to ask questions like this when you are completely stuck!

Best regards,


To report site rules violations or get help, contact a site moderator:

You can also contact site staff by submitting a support request »

Macro for replacing colors in Word 97 (VB)

Advanced search

Wordfast Pro
Translation Memory Software for Any Platform

Exclusive discount for users! Save over 13% when purchasing Wordfast Pro through Wordfast is the world's #1 provider of platform-independent Translation Memory software. Consistently ranked the most user-friendly and highest value

More info »
Protemos translation business management system
Create your account in minutes, and start working! 3-month trial for agencies, and free for freelancers!

The system lets you keep client/vendor database, with contacts and rates, manage projects and assign jobs to vendors, issue invoices, track payments, store and manage project files, generate business reports on turnover profit per client/manager etc.

More info »

Your current localization setting


Select a language

  • All of
  • Term search
  • Jobs
  • Forums
  • Multiple search