deleting blank lines in word

Lenovo thinkpad / R61
December 16, 2009 at 07:32:20
Specs: Windows XP
Is there a way in a Word Macro to delete blank lines in a text file

See More: deleting blank lines in word

Report •

December 16, 2009 at 08:52:10

The following Macro will find blank lines in a Word document and remove them:

Private Sub DeleteBlanks()

With Selection.Find
    .Text = "^p^p"
    .Replacement.Text = "^p"
    .Execute Replace:=wdReplaceAll, Forward:=True, _
End With
End Sub

This Macro finds single blank lines, and it would have to be re-run to remove double blank lines. If multiple blank lines is an issue, the macro could be extended to remove say all groups of 3 blank lines, then all pairs of two, and finally any remaining single blank lines.

Please note that the changes made by this Macro may not be reversible using the Undo function, so always make a backup before running a macro.

Alternatively you can do the same using Word's Find and Replace dialog box.

In the Find box enter ^p^p
and in the Replace box enter ^p


Report •

December 17, 2009 at 06:00:04
Thank-you! That worked great!!

Report •

Related Solutions

Ask Question