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

Cecilia Falk  Identity Verified
Local time: 00:34
English to Swedish
Jan 21, 2005

Hello,
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,
Cecilia


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


 

Jaroslaw Michalak  Identity Verified
Poland
Local time: 00:34
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
.ClearFormatting
.Font.ColorIndex = Color1
.Text = ""
With .Replacement
.ClearFormatting
.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: 00:34
English to Swedish
TOPIC STARTER
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
icon_wink.gif
Thanks again, it is great to be able to ask questions like this when you are completely stuck!

Best regards,
Cecilia


 


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






SDL Trados Studio 2017 only €435 / $519
Get the cheapest prices for SDL Trados Studio 2017 on ProZ.com

Join this translator’s group buy brought to you by ProZ.com and buy SDL Trados Studio 2017 Freelance for only €435 / $519 / £345 / ¥63000 You will also receive FREE access to Studio 2019 when released.

More info »
SDL Trados Studio 2017 Freelance
The leading translation software used by over 250,000 translators.

SDL Trados Studio 2017 helps translators increase translation productivity whilst ensuring quality. Combining translation memory, terminology management and machine translation in one simple and easy-to-use environment.

More info »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search