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

Cecilia Falk  Identity Verified
Local time: 01:43
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]


Direct link Reply with quote
 

Jabberwock  Identity Verified
Poland
Local time: 01:43
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]


Direct link Reply with quote
 

Cecilia Falk  Identity Verified
Local time: 01:43
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

Thanks again, it is great to be able to ask questions like this when you are completely stuck!

Best regards,
Cecilia


Direct link Reply with quote
 


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 MultiTerm 2017
Guarantee a unified, consistent and high-quality translation with terminology software by the industry leaders.

SDL MultiTerm 2017 allows translators to create one central location to store and manage multilingual terminology, and with SDL MultiTerm Extract 2017 you can automatically create term lists from your existing documentation to save time.

More info »
BaccS – Business Accounting Software
Modern desktop project management for freelance translators

BaccS makes it easy for translators to manage their projects, schedule tasks, create invoices, and view highly customizable reports. User-friendly, ProZ.com integration, community-driven development – a few reasons BaccS is trusted by translators!

More info »



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