Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2004
    Location
    Las Vegas, Nevada, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Change font color using macro (Word XP/2003)

    I have a large word document that needs to have selected lines changed to font color white to prevent them from printing.
    I use a simple macro to do this: Selection.Font.Color = wdColorWhite. I would like to create a new toolbar with a button linked to run this macro.

    Then I would like a second macro to go through the long document and change any text that is white back to standard black. Not sure how to write
    that macro.

    Finally, create a button on the new toolbar to run the second macro.
    Any help would be greatly appreciated.

    Richard Spring
    Richard Spring

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change font color using macro (Word XP/2003)

    Here is a macro that will change all white text to automatic (normally black):

    Sub White2Auto()
    With ActiveDocument.Content.Find
    .Text = ""
    .Replacement.Text = ""
    .ClearFormatting
    .Format = True
    .Font.Color = wdColorWhite
    .Replacement.ClearFormatting
    .Replacement.Font.Color = wdColorAutomatic
    .Execute Replace:=wdReplaceAll
    End With
    End Sub

    If you need these macros only in one document, you can put them in a module in the document itself. If you want to be able to use them in any document, you can put the macros in a module in your Normal.dot.

    To assign macros to toolbar buttons:
    <UL><LI>Select Tools | Customize.
    <LI>Activate the Toolbars tab.
    <LI>Click New...
    <LI>Specify a name for the toolbar.
    <LI>Important: specify whether it'll be stored in the document or in your Normal.dot (the latter makes it available throughout Word).
    <LI>Click OK.
    <LI>Activate the Commands tab.
    <LI>Again, specify where changes will be stored: the document or Normal.dot.
    <LI>Select Macros in the list of Categories.
    <LI>Select the first macro in the list of Commands.
    <LI>Drag it to your custom toolbar and drop it there.
    <LI>Right-click your new button and set its caption, style, etc.
    <LI>Repeat for the other macro.
    <LI>Click Close when done.[/list]This looks more complicated than it is (it takes longer to write down than to do it)

  3. #3
    3 Star Lounger
    Join Date
    Jan 2004
    Location
    Las Vegas, Nevada, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Change font color using macro (Word XP/2003)

    Thanks Hans:
    It works exactly as expected.

    Richard Spring
    Richard Spring

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •