I got a huge decument with more than 600 pages ...
... where there are empty pages that are a result of a manual page break (the page break being at the very top of the page).
If I delete this page break manually, an empty paragraph mark remains which also needs to be deleted.
Could somebody please come up with a code that deletes all these empty pages along with the ensuing blank paragraph mark.
Help is much appreciated. Thank you very much in advance.
Regards, Andreas
VBAMicrosoft WordMicrosoft Office
Last Comment
Andreas Hermle
8/22/2022 - Mon
Shums Faruk
Please try below:
Public Sub DeleteBlankPage()Selection.GoTo What:=wdGoToBookmark, Name:="\page"If isBlankSelection ThenSelection.DeleteEnd IfEnd SubPublic Function BlankPageSelection()For Each c In Selection.CharactersIf (c vbCr And c vbTab And c vbFormFeed And c " ") ThenBlankPageSelection = FalseExit FunctionEnd IfNextBlankPageSelection = TrueEnd Function
thank you very much for your professional support. I am afraid to say that the code is not working. Only one of these page breaks get selected, not the others and nothing is deleted.
Thank you
Shums Faruk
Thanks Andreas for coming back, please try below:
Sub DeleteEmptyPages(ByVal Worddoc As Word.Document)With Worddoc.Content.Find .ClearFormatting .Replacement.ClearFormatting .Text = ChrW(12) .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchWildcards = True .Execute Replace:=wdReplaceAllEnd WithEnd Sub
Open in new window