Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Feb 2003
    Location
    Annapolis, Maryland, USA
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    replace a list of words (2002 SP3)

    Is there a way, or does anyone have a macro, that will search a document for a list of words and phrases, and make those words and phrases bold?
    Michael Coleman
    BOMI International

  2. #2
    Star Lounger
    Join Date
    Nov 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: replace a list of words (2002 SP3)

    Where does the list of words come from?

  3. #3
    Star Lounger
    Join Date
    Feb 2003
    Location
    Annapolis, Maryland, USA
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: replace a list of words (2002 SP3)

    Right now it's a separate Word document, but I could put it anywhere.
    Michael Coleman
    BOMI International

  4. #4
    Star Lounger
    Join Date
    Nov 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: replace a list of words (2002 SP3)

    OK, I'm confused. If the list is just a Word document, then you can just select all and make everything bold, right? I am trying to see where the need for a macro comes in! Can you please explain your project/goal further?

  5. #5
    Star Lounger
    Join Date
    Feb 2003
    Location
    Annapolis, Maryland, USA
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: replace a list of words (2002 SP3)

    I really wasn't clear, was I? Sorry about that.

    I have one document that is a glossary. I want to pull out just the terms to create a separate list. (I can manage that part myself.) Then I want to search each chapter (each chapter is a separate Word file) for the words in that list of terms and make them bold wherever they appear.

    Thank you for your patience while I strive to articulate.

    Michael
    Michael Coleman
    BOMI International

  6. #6
    Star Lounger
    Join Date
    Nov 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: replace a list of words (2002 SP3)

    Ok, now you're making sense [img]/forums/images/smilies/smile.gif[/img] How long is this list? You can use a macro like this to bold the word Searches, and it would be fairly easy to manually code a list of say 20 terms. If the list is relatively long, then we may want to look at alternative routes.

    With Selection.Find
    .Text = "Searches"
    .Replacement.Text = "Searches"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

  7. #7
    Star Lounger
    Join Date
    Feb 2003
    Location
    Annapolis, Maryland, USA
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: replace a list of words (2002 SP3)

    I think there are about 200 words.
    Michael Coleman
    BOMI International

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

    Re: replace a list of words (2002 SP3)

    You could use a macro like this (substitute the correct path and filename of the document containing the words and phrases):

    Sub BoldWords()
    Dim doc1 As Document
    Dim doc2 As Document
    Dim par As Paragraph
    Dim strText As String
    Set doc1 = ActiveDocument
    Set doc2 = Documents("C:TestWordsAndPhrases.doc")
    With doc1.Content.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Replacement.Font.Bold = True
    .Replacement.Text = "^&"
    .MatchWholeWord = True
    For Each par In doc2.Paragraphs
    strText = par.Range.Text
    strText = Left(strText, Len(strText) - 1)
    .Execute FindText:=strText, Replace:=wdReplaceAll
    Next par
    End With
    doc2.Close
    End Sub

    Note: each word or phrase to be bolded should be a separate paragraph in the document listing them.

Posting Permissions

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