I want to be able to select a few lines of text, and then remove all
the line breaks (only) in that selection and replace the linebreak
with a space.

How do I do that? The following code does not work properly. I am
using Word 2003.

Thank you.
---------------------------------------------------------------
Sub SelectionRemoveHardLineBreaks()
Dim oRng As Word.Range
Set oRng = Selection.Range
With oRng.Find
.Text = "^p"
.Replacement.Text = " "
End With

Do While oRng.Find.Execute
With oRng
.Find.Execute Replace:=wdReplaceOne
End With
Loop

End Sub
---------------------------------------------------------------

Re: Removing Line Breaks in Selected Text by Helmut

Helmut
Sat Oct 20 14:37:55 PDT 2007

Hi,

Sub Macro6()
Dim rTmp As Range
Set rTmp = Selection.Range
With rTmp.Find
.Text = Chr(13)
.Replacement.Text = " "
.Wrap = wdFindStop
.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"

Re: Removing Line Breaks in Selected Text by kansaskannan

kansaskannan
Sat Oct 20 19:12:37 PDT 2007


Helmut:

Vielen dank fur die hilfe. Sehr nett von ihnen antwortet zu haben.

kannan


On Oct 20, 5:37 pm, Helmut Weber <nbhymsjxd...@mailinator.com> wrote:
> Hi,
>
> Sub Macro6()
> Dim rTmp As Range
> Set rTmp = Selection.Range
> With rTmp.Find
> .Text = Chr(13)
> .Replacement.Text = " "
> .Wrap = wdFindStop
> .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"