Conditional Page Break in MS Word


Background

For many years I have put up with using MS Word’s Insert | Break | Section Break (Odd Page) (now Layout | Breaks | Section Breaks | Odd Page in Word 2016) to force a page break when you want a new chapter/section/heading to begin on an odd page.  Now this works fine, except that if the Section Break (Odd Page) is placed on an odd numbered page, an extra even numbered completely blank page gets inserted to enforce the condition.  No big deal really, unless you don’t like completely blank pages.

And right now, I have a requirement to ensure that there are no blank pages in a document I am writing – the text “This page has been intentionally left blank” is supposed to be added to blank pages.

[Aside: I refuse. I cannot stand seeing intrinsically false statements – like “This gate must remain closed at all times” and “This page has been intentionally left blank“. I will be putting “This page has been intentionally left for you to record your own notes.”]

So I had to finally solve my problem.  How to add conditional page breaks in MS Word so that if I was about to insert a Section Break (Odd Page) I could add my own page break and “This page has been intentionally left for you to record your own notes.” text BEFORE the Section Break (Odd Page) so that there would be no completely blank even numbered pages.

Here is how I did it – this is “How to insert a conditional page break in MS Word”

  1. Press <Ctrl+F9> (Windows) or <Cmd+F9> (Mac OS X) to insert a field code.  This will make a stylised pair of braces appear – {} with the cursor between the braces.
  2. Enter the following text between the braces, using<Ctrl+F9> (Windows) or <Cmd+F9> (Mac OS X) to insert nested fields as you go

{ IF { =MOD({PAGE},2) } = "0" "" "{QUOTE 12}Notes."}

  1. Press <F9> to update the field
  2. Now select Insert | Break | Section Break (Odd Page) or  Layout | Breaks | Section Breaks | Odd Page to insert the section break immediately after the field

Tip: Press <Alt+F9> (Windows) or <Option+F9> (Mac OS X) to reveal/hide the field codes.

Explanation

Lets look at the part of the nested expression:
{ IF { =MOD({PAGE},2) } = "0" "" "{QUOTE 12}Notes."}

  • Firstly, {PAGE} returns the current page number, and {QUOTE 12} is a page-break character.
  • { =MOD({PAGE},2) } divides the page number by 2, and gives you the remainder, which must be either "0" if {PAGE} is an even page, or "1" if {PAGE} is an odd page.
  • The {IF  } construct evaluates the expression { =MOD({PAGE},2) }="0" and prints”” (nothing) if it is true (even page) or prints "{QUOTE 12}Notes" if the expression is false (odd page)
  • Note: the quotes around the "0" are optional, BUT if omitted, there must be a space between the = and the number
  • Note: I could have achieved the exact same result by saying:
    { IF { =MOD({PAGE},2) } = 1 "{QUOTE 12}Notes." ""} [Note the space between = and 1]
  • Note: I could have actually put a page-break character in the IF expression instead of using {QUOTE 12}, but it is not as readable.

Optional extras!

You could easily change the expression to in fact completely replace the Insert | Break | Section Break (Odd Page) or  Layout | Breaks | Section Breaks | Odd Page function if you did not want to use the section break at all.  The following would add a page break {QUOTE 12} followed by a additional page break that would only be applied if the new page was an even numbered page, which could be useful if you wanted to start new chapters on odd pages, but didn’t want to use the section break at all. [Note the space between = and 0]

{QUOTE 12}{ IF { =MOD({PAGE},2) } = 0 "{QUOTE 12}" ""} Heading Text on Odd Page

Read my other MS Word rant here

Credits

I thought I’d found an answer on this site, but unfortunately the example given had unmatched braces, and was missing the quotes around the "0" (or space before) in the IF expression, so I had to search further.  This excellent tutorial helped me fix the unmatched braces, and the MS office support site made me twig about the missing quotes around the "0" (I later discovered that leaving a space between the = and the number would also do the trick) and finally macropod[_2_]’s comment on this post is where I discovered that {QUOTE 12} would insert a page break.

RedNectar

 

 

 

Advertisements

About RedNectar Chris Welsh

Professional IT Instructor. All things TCP/IP, Cisco or VoIP
This entry was posted in Microsoft, Microsoft Word, opinion, rant and tagged , , , , , , , , , . Bookmark the permalink.