Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Feb 2008
    Location
    Beckenham, United Kingdom
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi there

    I need to be able to find, for example, the word 'brother' throughout a document when it occurs as a word on its own but not when it occurs as past of another word e.g. 'brother-in-law' and replace it with, say, 'sister'. I had thought that the 'whole words' option would do this but it does not. This option seems to treat a dash as an indication an end of word (like a space). Please can someone tell me how I can achieve this?

    Many thanks for any help.

    ArchieD

  2. #2
    3 Star Lounger E_OGRADY's Avatar
    Join Date
    Dec 2000
    Location
    Melbourne, Victoria, Australia
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I was not aware of this behaviour, but I have had a look and found that what you say is correct, however to overcome the action I checked the box "Use Wildcards" this worked for me in Word 2003.
    By the way your link at the bottom of your post is (I think) incorrect.
    Attached Images Attached Images

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='ArchieDog' post='770091' date='11-Apr-2009 01:35']I need to be able to find, for example, the word 'brother' throughout a document when it occurs as a word on its own but not when it occurs as past of another word e.g. 'brother-in-law' and replace it with, say, 'sister'.[/quote]
    We recently had a thread about a Find using Word's wildcard search feature to look for a word between certain desired "boundary" characters. The problem was that the find included the boundary characters, so it would have to be tweaked a bit to replace only the word between them. It's late here, so I can't work on it now, but here is the other thread for reference: [topic="761894"]Find Upper Case Whole Words[/topic].

  4. #4
    New Lounger
    Join Date
    Apr 2009
    Location
    UK
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='ArchieDog' post='770091' date='11-Apr-2009 09:35']Hi there

    I need to be able to find, for example, the word 'brother' throughout a document when it occurs as a word on its own but not when it occurs as past of another word e.g. 'brother-in-law' and replace it with, say, 'sister'. I had thought that the 'whole words' option would do this but it does not. This option seems to treat a dash as an indication an end of word (like a space). Please can someone tell me how I can achieve this?

    Many thanks for any help.

    ArchieD[/quote]

    I can give you two more simple ways - 1 quick, 1 reuseable

    Quick - first Find/Replace "brother-" and replace with something like "**CHANGEBACK**" then do your other replacements - then change it back to "brother-" - negates the issue!

    Reusable - Create a macro that finds (for example) "brother " (note the space), then edit the macro in the VBA window.

    [codebox]Sub Macro1()
    '
    ' Macro1 Macro
    ' Find and replace multiple forms of a word.
    '
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = "brother "
    .Replacement.Text = "anything "
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    End Sub[/codebox]

    You can then copy and repeat the WITH statement to have any and all variants of our word "brother." "brothers" etc. and if there is a specific variant that you want to be left alone, then you could always add a WITH statement at the beginning that alters it to something like "**CHANGEBACK**" and another at the end of the code that looks for "**CHANGEBACK** and turns it into what it should be:

    [codebox]Sub Macro2()
    '
    ' Macro2 Macro
    ' Find and replace multiple forms of a word.
    '
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = "brother-"
    .Replacement.Text = "**CHANGEBACK**"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With

    With Selection.Find
    .Text = "brother "
    .Replacement.Text = "anything "
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With

    With Selection.Find
    .Text = "**CHANGEBACK**"
    .Replacement.Text = "brother-"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    End Sub[/codebox]


    If you have this embedded in your Normal.dot Template, then all you have to do whenever you need to use it is Alt+F11 to open your VBA window and alter it as needed for the task.


    Bird

  5. #5
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post
    Why not try replacing the expression "_brother_ " (where _ = space) with, say, "_sister_". Of course this wouldn't catch a sentence that began with the word Brother, but you could try finding these with an expression like "Brother_" (with Match case turned on). For an end of sentance use "_brother." as the search term.

  6. #6
    New Lounger
    Join Date
    Feb 2008
    Location
    Beckenham, United Kingdom
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am pleased to know that I was not missing something obvious. Thank you all very much for your replies and your suggestions.

    Thanks too for pointing out the incorrect link.

    ArchieD

Posting Permissions

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