How to Quickly Remove Blank Paragraphs at the Beginning of Each Page in Your Word Document

In this article, there is the way to quickly remove blank paragraphs at the beginning of each page in your Word document.   Remove Blank Paragraphs at the Beginning of Each Page

Every once in a while, when copy and paste contents from one document to another, change of text formatting can result in extra blank paragraphs at the beginning of some pages. And the practical demand is to delete just the blank paragraphs at the beginning of some pages instead of all blank ones in the entire document. To quickly get rid of them will require help from a macro.

Run Word Macro to Remove Blank Paragraphs

  1. First and foremost, click “Developer” tab in the Ribbon and then the “Visual Basic” command. But, if the “Developer” tab is not available yet, just press “Alt+ F11” instead.
  2. Next in the VBA editor, click “Normal” project on the left.
  3. Then click “Insert” on the menu bar.
  4. In the drop-down menu, choose “Module”.Click "Normal"->Click "Insert"->Click "Module"
  5. This way you have inserted a new module under “Normal” project.
  6. Next step, open the module by double click on it.
  7. In the right side of the coding area of the module, paste these codes there:
Sub RemoveAllBlankParagraphsAtTopOfPage()
  Dim objDoc As Document
  Dim objPara As Paragraph
  Dim nPageNum As Integer
  Dim objRange As Range
  Dim nTotalParaNum As Long
  Dim nPageParaNum As Long
  Dim nParaNumRemoved As Long

  Application.ScreenUpdating = False
 
  ' Initialize and count the total number of paragraps in the document.
  Set objDoc = ActiveDocument
  nTotalParaNum = objDoc.Paragraphs.Count
  nPageNum = 0
 
  ' Step through each page and delete blank paragraphs at the top of each page in the document.
  For nPageNum = 1 To Selection.Information(wdNumberOfPagesInDocument)
    Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=nPageNum
    Set objRange = Selection.Range
    objRange.End = Selection.Bookmarks("\Page").Range.End
    objRange.Select

    nPageParaNum = nPageParaNum + objRange.Paragraphs.Count
 
    For Each objPara In objRange.Paragraphs
      If Len(objPara.Range.Text) = 1 Then
        objPara.Range.Delete
        nParaNumRemoved = nParaNumRemoved + 1
      Else
        Exit For
      End If
    Next objPara
 
    If nParaNumRemoved + nPageParaNum >= nTotalParaNum Then
      Exit For
    End If
  Next nPageNum
  Application.ScreenUpdating = True
  Set objDoc = Nothing
End Sub
  1. Then click “Run” button or press “F5” instead to execute the macro.Paste Codes->Click "Run"

When the process is done, you will receive a message box, such as below:Message Box Showing Result

Mind the Document Corruption

Your documents can corrupt anytime without notifying you. It’s sad enough already to receive broken data. In such scenarios, you must know the right thing to do and that is to acquire an advanced tool to recover doc immediately, although it’s better to get one in advance.

Author Introduction:

Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including xlsx recovery and pdf repair software products. For more information visit www.datanumen.com