Removing double empty lines (two 0x0a 0x0a in a row)

CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

MACRO: REMOVEEMPTYLINES

PURPOSE: To remove double empty lines (two 0x0a 0x0a in a row)

WHY: When converting from mac/unix/dos text file formats some programs
stuff up by making double lines which is annoying

HOW: Just mark your area and run the macro


Sub RemEmptyLines()
Dim comp
str = ActiveDocument.Selection.Text
str1 = “”
comp = vbLf + vbLf
comp2 = vbLf + vbLf
i = 1
Do While (i < Len(str)+1) Do While Mid(str, i, 2) = comp i = i + 1 Loop str1 = str1 + Mid(str, i, 1) i = i + 1 Loop ActiveDocument.Selection.Text = str1 End Sub

Date Last Updated: February 1, 1999

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read