A macro which has operated properly many times in the past halted with an
error this morning. The debugger indicated line 10 below as the error.
After trying to determine why, I did a manual find/replace and the
replace window came up with use wildcards checked. I guess that the last
replace I did yesterday (different document) used wildcards and Word
remembered this setting. How do I unset this in the macro? I am using
Word 2002.
1 Selection.WholeStory
2 Selection.Find.ClearFormatting
3 Selection.Find.Replacement.ClearFormatting
4 With Selection.Find
5 .Text = "^l"
6 .Replacement.Text = " "
7 .Forward = True
8
9 End With
10 Selection.Find.Execute Replace:=wdReplaceAll
11 With Selection.Find
12 .Text = " ^p"
13 .Replacement.Text = "^p"
14 .Forward = True
15
16 End With
Jonathan West - 21 Jul 2005 16:33 GMT
Hi Al,
These articles will show you what you need to do.
Clear settings from Find and Replace dialog to prevent unexpected results
from future Find or Replace operations
http://www.word.mvps.org/FAQs/MacrosVBA/ClearFind.htm
Flush bad karma from Word's find facility after an unsuccessful wildcard
search
http://www.word.mvps.org/FAQs/MacrosVBA/FlushFR.htm

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
>A macro which has operated properly many times in the past halted with an
> error this morning. The debugger indicated line 10 below as the error.
[quoted text clipped - 20 lines]
> 15
> 16 End With
Helmut Weber - 21 Jul 2005 16:50 GMT
Hi Al,
use
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
always before serching and (!) after as well.
Greetings from Bavaria, Germany
Helmut Weber, MVP, WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"