Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    313
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro to Bold Word (XP/2003)

    Hi all - I need a macro to bold a certain word throughout a file. The professor does not want to search and replace.

  2. #2
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Bold Word (XP/2003)

    Hi Melanie,

    You'll need to be a bit more specific.

  3. #3
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Bold Word (XP/2003)

    Is this all you need? (replace "Foo" with the word you need bolded)

    <pre>Sub BoldAWord()
    With ActiveDocument.Content.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .MatchWildcards = False
    .MatchWholeWord = True
    .Format = False
    .Text = "Foo"
    .Replacement.Text = "^&"
    .Replacement.Font.Bold = True
    .Execute Replace:=wdReplaceAll
    End With
    End Sub
    </pre>


  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    313
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Bold Word (XP/2003)

    Sorry - week before classes start - I am get swamped at the help desk......
    He wants to search through a several page document for a certain word and change it from regular font to bold font. I thought he could just do a search and replace each regular word with the same word in bold face. He wants a macro to do it. Maybe I am missing something though.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Macro to Bold Word (XP/2003)

    Maybe he doesn't understand all of his Find and Replace options? Any macro is either going to do the same Find and Replace he could do, or it is going to Find, then manually format, then Find again, etc. I think perhaps you might encourage him to learn the features rather than rely on a one-off macro.

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    313
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Bold Word (XP/2003)

    I sent him the macro - he is very grateful.

    Thank you!

  7. #7
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Bold Word (XP/2003)

    Here is a slight variation of Andrew's macro. With this variation, you do not have to hard code the word you want to bold into the macro. You selecet the word or combination of words and run the macro.

    <pre>Sub BoldAWord()
    Dim strBold As String
    strBold = Selection.Text
    With ActiveDocument.Content.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .MatchWildcards = False
    .MatchWholeWord = True
    .Format = False
    .Text = strBold
    .Replacement.Text = "^&"
    .Replacement.Font.Bold = True
    .Execute Replace:=wdReplaceAll
    End With
    End Sub
    </pre>

    Legare Coleman

Posting Permissions

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