Written by Allen Wyatt (last updated November 23, 2023)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365
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:
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:
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.
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!
Headings form the outline of your document and hopefully give it an easy-to-follow organization. If you want to share ...
Discover MoreIf 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 MoreIf your heading styles are designed to add extra space before the heading, you may be surprised when that extra space is ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-02-12 23:53:04
SHweta
Thanks a ton! I was looking for this !
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.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments