Macro Help: Replace ^p in Selected Text

W

Wahala

Sub FormatEraseParagraph()
'
' FormatEraseParagraph Macro
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = " "
.Selection
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub


I need this macro to work on the paragraph that I have Selected
(highlighted) in the Word document. However, when I run this macro, it works
on the whole document EXCEPT what I have selected. Can you fix it for me?
 
H

Helmut Weber

Hi,
if you want to delete the paragraph mark
of the one completely selected paragraph, this would be sufficient:
Selection.Characters.Last.Delete
The following works on paragraph the cursor is in
or on the first of several selected paragraphs:
Selection.Paragraphs(1).Range.Characters.Last.Delete
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 

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