Macro only selected text

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created a macro that replaces paragraph marks with a blank. I only want it
to do this for selected text. Problem is, it does it for non-selected text as
well.

How can I make this macro only perform the replacement for selected text
 
Hi Greg In Atl,

like this:

Sub T5()
If Selection.Type = wdSelectionIP Then Exit Sub
With Selection.Range.Find
.Text = "^p"
.Replacement.Text = " "
.Execute Replace:=wdReplaceAll
End With
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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

Back
Top