Ms Word Macro to delete all paragraph mark or new line character

Many times, while pasting text from other source to Ms Word, we end up getting unnecessary newline character at the end of each line. This was bothering me since long and I wanted a smart way to get rid the un wanted newline character. Then I found the following macro that solves the problem in 1 click.

Sub DeleteLNewLine()
Dim oRng As Word.Range
Set oRng = Selection.Range
  If oRng.Characters.Last = Chr(13) Or oRng.Characters.Last = Chr(11) Then
    oRng.End = oRng.End - 1
  End If
  oRng.Text = Replace(Replace(oRng.Text, Chr(11), " "), Chr(13), " ")
lbl_Exit:
  Exit Sub
End Sub

1 thought on “Ms Word Macro to delete all paragraph mark or new line character

Leave a Reply