Moving Headings to the Next Page

Written by Allen Wyatt (last updated November 23, 2023)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365


1

Bruce would like to have any Heading 1 paragraphs start at the top of the next page if they would otherwise fall into the lower 1/3 of the previous page. He wonders if there is a way to do this, perhaps with a macro.

Word has a built-in capability to adjust pagination based on the characteristics of a paragraph. (A heading is a type of paragraph, so this applies to headings just as easily as it does to any other type of paragraph.) On the Line and Page Breaks tab of the Paragraph dialog box you can see these three settings:

  • Page Break Before. This setting, when chosen, forces the paragraph to always start at the top of the next page.
  • Widow/Orphan Control. This setting, when chosen, ensures that if a paragraph requires multiple lines, a single line of the paragraph won't be left alone at the bottom or top of a page. Even though most headings are single lines, this is a handy setting for headings in case they require multiple lines.
  • Keep with Next. This setting, when chosen, ensures that the paragraph stays with the paragraph that follows it. This is great for a heading, as it ensures that a heading must be with at least two lines of the paragraph that follows it. (This presumes that you have the following paragraph formatted for Widow/Orphan Control.)

While these controls are fantastic, they won't meet Bruce's needs because none of them will force a heading to the next page if it would normally appear in the bottom third of a page. This means that Bruce needs to come up with a workaround that will accomplish what he wants.

One approach is to define two Heading 1 styles. One of the styles could be considered "normal," meaning that it will appear in the normal flow of your document text. The other style could be based on the regular Heading 1, but it could have the Page Break Before setting (discussed earlier) enabled. These two styles would be very easy to use; all you need to do is make sure that all regular Heading 1 styles are used throughout the document. Then, before printing, you could manually go through the document, one page at a time, and apply the secondary Heading 1 style to those headings that are too far down the page for your liking. They would automatically be moved to the top of the next page, Word would repaginate the document, and you could continue scanning for headings that needed to be moved.

The reverse approach would be to actually place manual page breaks before all your Heading 1 paragraphs. If you then select the page break and Heading 1 paragraph, you could define it as a building block that you could later use for all your headings. (Just insert the building block and then modify the text in the actual heading paragraph.) Before printing, manually go through the document and, if you see that a heading could be moved to the preceding page, delete the page break that is just in front of the heading paragraph. Word moves the heading to the preceding page, repaginates the document, and you could continue scanning for headings that could be moved.

If the lower third of a page is not deeper than 10 lines of text, then you could use a rather novel approach to your headings: Format them with a drop cap. A drop cap can be up to 10 lines deep; all you need to do is make sure that the "dropped" character is something that is very, very thin. For instance, you might try using an uppercase letter I. Format the single character as a very small point size and make its color white. Then select the character and make it a 10-line drop cap. If the entire drop cap cannot fit on the page, Word obligingly moves it to the next page. You may have to play with some of the formatting characteristics to get exactly what you want, but it is the only potential workaround that doesn't involve any manual processing on your part.

If you want to use a macro to do the formatting, the most practical approach is to have the macro adjust the positions of any Heading 1 paragraphs after the document is complete. The idea is for the macro to search from the beginning of the document, looking for any Heading 1 paragraphs. If one is found and it is positioned at more than 66% of the page height, then a page break is inserted to move the heading to the next page. The following macro performs all these tasks.

Sub AdjustHeading()
    Dim CursorVert As Single
    Dim Pgheight As Single
    Dim styleName As String

    styleName = "Heading 1"
    If ActiveDocument.Styles(styleName).ParagraphFormat.PageBreakBefore Then
        MsgBox styleName & " has 'Page break before' set. Run aborted"
        Exit Sub
    End If
    Selection.HomeKey unit:=wdStory
    With Selection.Find
        .ClearFormatting
        .Style = ActiveDocument.Styles(styleName)
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
    End With
    Do While Selection.Find.Execute
        If Asc(Selection.Range.Characters(1)) = 12 Then
            Selection.MoveStart unit:=wdCharacter, Count:=1
        End If
        With ActiveDocument.Sections(Selection.Information(wdActiveEndSectionNumber)).PageSetup
            CursorVert = Selection.Information(wdVerticalPositionRelativeToPage) - .TopMargin
            Pgheight = .PageHeight - .TopMargin - .BottomMargin
        End With
        If CursorVert > Selection.Style.ParagraphFormat.SpaceBefore Then
            If CursorVert / Pgheight > 0.66 And Len(Selection.Range) > 1 Then
                Selection.End = Selection.Start
                Selection.TypeText Chr(12)
            End If
        End If
        Selection.Start = Selection.End
    Loop
End Sub

In order for this macro to operate properly, you should make sure that your Heading 1 style doesn't have the Page Break Before attribute set. The macro determines the page height of the current section to accommodate documents that vary page height from section to section. Page height is calculated by subtracting the top and bottom margins from the paper height.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12564) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Determining Word Versions of Documents

If you know where to look, you can figure out which version of Word was last used to work on a document. It takes some ...

Discover More

Copying Formats to a New Worksheet

Do you want to copy formats from one worksheet to another? You can do so easily by using the Format Painter. It even ...

Discover More

Default Cell Movement when Deleting

Delete a cell or a range of cells, and Excel needs to figure out how to rearrange the void left by the deletion. You can ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

More WordTips (ribbon)

Sharing Headings with Others

Headings form the outline of your document and hopefully give it an easy-to-follow organization. If you want to share ...

Discover More

Formatting All Headings At Once

If you need to apply a common formatting change to all the headings in your document, a quick way to do it is to use the ...

Discover More

Getting the Expected Space Before a Heading

If your heading styles are designed to add extra space before the heading, you may be surprised when that extra space is ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 7?

2020-02-12 23:53:04

SHweta

Thanks a ton! I was looking for this !


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.