Selection.Find.Execute replaces throughout entire document!

A

Alex Turner

I recorded the following macro while doing a find replace for
paragraph marks that I wanted to convert to two spaces (when asked if
I wanted to keep searching the entire document, I said 'No'):


Sub RemoveParagraphMarks()
'
' RemoveParagraphMarks Macro
' Macro recorded 11/27/2004 by aturner
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub


When I use this macro, however, Word replaces ALL paragraph marks in
my entire document with two spaces, ignoring the selection range, even
though the same text is still selected after the macro completes, now
without paragraph marks.

How do I get Word to respect my selection range while doing
Selection.Find.Execute?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top