Skip to content

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

Macro to delete all new line character from selected text in 1 click

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

Leave a Reply

Your email address will not be published. Required fields are marked *