Thread: [Solved] Find & Replace Unique word
View Single Post
 
Old 05-03-2017, 06:04 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,598
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Your code doesn't compile so I don't see how it is finding or not finding anything.

Find whole word is disabled when certain characters are included in the find string. You could do this in steps (just make sure your document is not a thesis on the behavior of the Aardvark):

Code:
Sub InSteps()
Dim oRng As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = "^^"
    .Replacement.Text = "Aardvark"
    .Execute Replace:=wdReplaceAll
    Set oRng = ActiveDocument.Range
    .Text = "Aardvarkmb"
    .Replacement.Text = "Test"
    .MatchWholeWord = True
    .Execute Replace:=wdReplaceAll
    Set oRng = ActiveDocument.Range
    .Text = "Aardvark"
    .Replacement.Text = "^^"
    .MatchWholeWord = False
    .Execute Replace:=wdReplaceAll
  End With
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/