Ed
Thu May 26 12:06:55 CDT 2005
Okay - I think I follow this. ResetSearch is only to make sure nothing is
left over from a previous search?
And did I modify my code correctly?
' Open doc and replace
Set doc = Documents.Open(fName & dName)
Set rng = doc.Range
ResetSearch
With rng.Find
.Text = strFind
.Replacement.Text = strRepl
.Format = False
.Wrap = wdFindContinue
If .Execute (Replace:=wdReplaceAll) Then
Debug.Print dName
End If
End With
doc.Close SaveChanges:=wdSaveChanges
ResetSearch
"Helmut Weber" <elmkqznfwvccbf@mailinator.com> wrote in message
news:ouub91trnb8ntbj7bvclhcls3l0c2ijs13@4ax.com...
> Hi Ed,
>
> like this:
>
> Sub test712348()
> Dim rng As Range
> Set rng = ActiveDocument.Range
> ResetSearch
> With rng.Find
> .Text = "a"
> .Replacement.Text = "b"
> If .Execute(Replace:=wdReplaceAll) Then
> MsgBox "found and replaced"
> Else
> MsgBox "nothing found, nothing replaced"
> End If
> End With
> ResetSearch
> End Sub
> ' ---
> Public Sub ResetSearch()
> With Selection.Find
> .ClearFormatting
> .Replacement.ClearFormatting
> .Text = ""
> .Replacement.Text = ""
> .Forward = True
> .Wrap = wdFindContinue
> .Format = False
> .MatchCase = False
> .MatchWholeWord = False
> .MatchWildcards = False
> .MatchSoundsLike = False
> .MatchAllWordForms = False
> ' plus some more if needed
> .Execute
> End With
> End Sub
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP
> "red.sys" & chr(64) & "t-online.de"
> Word XP, Win 98
>
http://word.mvps.org/
>