
Find/Replace code not working - why?
Here's the code, running in VB:
dim oApp as Word.Application
dim sTextToFind as String
dim sReplaceWith as String
Set oApp = CreateObject("Word.Application")
sTextToFind = "#NAME#"
sReplaceWith = "Mike Smith"
With oApp.Selection.Find
.Forward = True
.Wrap = wdFindContinue
.ClearFormatting
.Replacement.ClearFormatting
.Text = sTextToFind
.Replacement.Text = sReplaceWith
.Execute
End With
When I run this in a debug session the value of the .Found property is
true, but the original text is not replaced.
Thanks in advance,
Mike