How i can delete Only the blank lines at the top of each page in VBA word 2016.
I tried to do something like this
Sub RemoveBlankParas()
Dim para As Paragraph
For Each para In ActiveDocument.Paragraphs
If Len(para.Range.Text) = 1 Then
'only the paragraph mark, so..
para.Range.Delete
End If
Next para
End Sub
But the problem with that code is that it removes all blank lines not only at TOP of the page but also at the center or bottom of the page.
Also if you can implement removing blank pages(Pages with no words on it) in the macro that will be fantastic. Thanks.
UPDATE 2: I figured out how to delete the last manual page-break in the document.
UPDATE 1: I modified the following code to delete blank pages. If a blank page consists of any or a number of blank lines (and not other text), then the original code will delete all of those since they technically start at the top of a page. Then in the second pass it will look just for Page Breaks as the only 'paragraph' on the page. If found, it will be deleted.
I think the following may solve the issue of deleting the blanks at the top of each page. Keep in mind that Word will continue to 'redraw' the page as text is deleted. But more importantly, a paragraph can be any size which means 1, 2, or 20 'lines'.