Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Aug 2003
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    macro to change font color (Word 2003)

    I need a macro that would search in a document for specific words and if the word is found, change the font color to red and highlight. I have all of it figured out execpt how to get the font color to change. Any help appreciated. Here's what I have so far:
    Sub forbidden_words()
    '
    ' forbidden_words Macro
    ' Macro recorded 10/31/2007 by mcd
    '
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
    .Text = "pure"
    .Replacement.Text = "pure"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.HomeKey Unit:=wdStory
    End Sub

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

    Re: macro to change font color (Word 2003)

    Add this line:
    <code>
    .Replacement.Font.Color = wdColorRed</code>

  3. #3
    2 Star Lounger
    Join Date
    Aug 2003
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macro to change font color (Word 2003)

    thanks. That did the trick. I forgot to ask this in my first post. The font also need to be changed from regular to bold.

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

    Re: macro to change font color (Word 2003)

    You can use IntelliSense to find out things like this. If you type <code>.Replacement</code> and then a period, IntelliSense will display a list of possibilities, among which Font. Type the first letters of Font until it is selected in the list, then press Tab (or click on Font). Type a period again, and IntelliSense will pop up a list again, this time containing properties such as Color, Size, Bold etc.
    <code>
    .Replacement.Font.Bold = True</code>

  5. #5
    2 Star Lounger
    Join Date
    Aug 2003
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macro to change font color (Word 2003)

    Thanks. This is very helpful.

Posting Permissions

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