Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word Macro: Change Format in Doc A from word list in Doc B

    I spend a lot of time looking through proposals and RFP responses.
    One of the things I look for are what I call "Weasel Words". Words like "however, but and while".

    I would really like to be able to automate this part of the review process by creating a list of weasel words in one document, and getting a macro to search the other (proposal) document for these words and make the font red and larger for the selected word on the weasel word list.

    So far, my beginner attempts have failed. Anyone have a sample macro they would not mind sharing?

    Thanks!

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,379
    Thanks
    207
    Thanked 829 Times in 762 Posts
    STC,

    Welcome to the lounge as a poster.

    Sounds like something you could adapt a concordance to do. That is, create an index to those words.
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Willow Grove, Pennsylvania, USA
    Posts
    196
    Thanks
    4
    Thanked 46 Times in 38 Posts
    RetiredGeek's idea is not bad, but the macro you asked for isn't too hard (when you know how! )

    Let's assume you create "document B" with one word on each line with an Enter (paragraph mark) at the end of the line -- that is, each word is alone in a paragraph. Name the file weasel.doc and put it in your Documents folder. Open a "document A" and run this macro. For each one-word paragraph in weasel.doc, it will run a Replace All in "document A" to replace the word with itself but formatted in red and 14 point font.

    Code:
    Sub WeaselWords()
        Dim myRange As Range
        Dim DocToCheck As Document
        Dim DocWithWords As Document
        Dim WordToCheck As String
        Dim para As Paragraph
        
        Set DocToCheck = ActiveDocument
        Set DocWithWords = Documents.Open(FileName:="weasel.doc")
        
        For Each para In DocWithWords.Paragraphs
            WordToCheck = para.Range.Words(1)
            If (WordToCheck <> "") And (WordToCheck <> vbCr) Then
                Set myRange = DocToCheck.Range
                With myRange.Find
                    .Text = WordToCheck
                    .Format = True
                    .Replacement.Text = "^&"
                    .Replacement.Font.ColorIndex = wdRed
                    .Replacement.Font.Size = 14
                    .Execute Replace:=wdReplaceAll
                End With
            End If
        Next para
        
        DocWithWords.Close SaveChanges:=wdDoNotSaveChanges
    End Sub
    Last edited by Gary Frieder; 2012-01-07 at 00:34. Reason: Added tags to indent code

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,379
    Thanks
    207
    Thanked 829 Times in 762 Posts
    J.J.

    Nice Job!
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


Tags for this Thread

Posting Permissions

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