Remove all empty paragraphs from Word Document using VBA Code
In a large Microsoft Word Document that consist of many pages removing of blank or empty paragraphs or lines is so time consuming and tedious task, we have already discussed how to remove all empty paragraphs using Kutools and Find & Replace Dialog Box. In this blog post i will explain how to remove all empty or blank paragraphs or lines from word document using Macros & VBA Code.
Steps to Remove empty paragraphs from word document
Open VBA Editor(by Pressing ALT+F11), from the Menu Click on Insert and then Click on Module as shown bellow.
Click this link if you want to learn in detail how to use and RUN VBA Code

Past either of the following code into the module.
The following code will Remove all empty or blank paragraphs or lines containing no whitespaces
Sub removeAllEmptyParagraphs()
Dim ePrg As Word.Paragraph
For Each ePrg In ActiveDocument.Paragraphs
If Len(ePrg.Range) = 1 Then ePrg.Range.Delete
Next
End Sub
The following code will Remove all empty or blank paragraphs or lines containing some inline whitespaces
Sub DeleteAllEmptyParagraphsWithSpaces()
Dim wParagraphs As Word.Paragraph
Dim var
Dim SpCounter As Long
Dim wChar As Word.Characters
For Each wParagraphs In ActiveDocument.Paragraphs
If Len(wParagraphs.Range) = 1 Then
wParagraphs.Range.Delete
Else
SpCounter = 0
Set wChar = wParagraphs.Range.Characters
For var = 1 To wChar.Count
If Asc(wChar(var)) = 32 Then
SpCounter = SpCounter + 1
End If
Next
If SpCounter + 1 = Len(wParagraphs.Range) Then
wParagraphs.Range.Delete
End If
End If
Next
End Sub
After pasting either of the above VBA Code Press CTRL+S (If Prompt Message Click Yes), then Close VBA Editor.


Now to Test or RUN Your VBA Coded Macro, Press ALT +F8 , this open Macro Dialog Box containing a list of Macros Select your created one and Click on RUN Button as shown bellow.

After Clicking on RUN Button in the Micros Dialog Box as above your VBA Coded Macro will be executed and all empty or blank paragraphs will be removed from your entire document.
I hope this tutorial will help to delete or remove all empty paragraphs in word document using VBA Code.
if you have any queries please contact us using the details given on our contact us page.
Thank you.