In a macro, I used Ctrl+Find to locate the word "East" in an addr line
and change it to "E". While this works fine, it also changes
"Eastwood" to "Ewood". I tried using MatchWholeWord=True but it didn't
help.
I notice that when I use Ctrl+Find outside of the macro environment,
it allows me to choose "Find Whole Words Only'.
My question is how do I make the macro using Ctrl+Find to use the
"Find Whole Words Only" command.
Thanks muchly for your time and expertise
Joanne

Re: Match Whole Word by Ed

Ed
Fri Jan 23 15:38:44 CST 2004

The whole Selection.Find code as recorded my the Macro Recorder usually
looks something like this:
Selection.Find.ClearFormatting
With Selection.Find
.Text = "your text here"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute

You can set these to the desired parameters. For more on this, see Execute
Method (Find Object) in the VBA help.

Ed

"Joanne" <jebuss@msn.com> wrote in message
news:OVlwEHe4DHA.2404@TK2MSFTNGP12.phx.gbl...
> In a macro, I used Ctrl+Find to locate the word "East" in an addr line
> and change it to "E". While this works fine, it also changes
> "Eastwood" to "Ewood". I tried using MatchWholeWord=True but it didn't
> help.
> I notice that when I use Ctrl+Find outside of the macro environment,
> it allows me to choose "Find Whole Words Only'.
> My question is how do I make the macro using Ctrl+Find to use the
> "Find Whole Words Only" command.
> Thanks muchly for your time and expertise
> Joanne



Re: Match Whole Word by Peter

Peter
Fri Jan 23 15:43:15 CST 2004

Hi Joanne

In the With block that's doing the Find set ".MatchWholeWord = True".
So your macro will look something like:

Public Sub EastToE
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "East"
.Replacement.Text = "E"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

HTH + Cheers - Peter


Joanne <jebuss@msn.com> wrote in news:OVlwEHe4DHA.2404@TK2MSFTNGP12.phx.gbl:

> In a macro, I used Ctrl+Find to locate the word "East" in an addr line
> and change it to "E". While this works fine, it also changes
> "Eastwood" to "Ewood". I tried using MatchWholeWord=True but it didn't
> help.
> I notice that when I use Ctrl+Find outside of the macro environment,
> it allows me to choose "Find Whole Words Only'.
> My question is how do I make the macro using Ctrl+Find to use the
> "Find Whole Words Only" command.
> Thanks muchly for your time and expertise
> Joanne
>