Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, and 2013. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Making Sure a Document Always Has an Even Number of Pages.

Making Sure a Document Always Has an Even Number of Pages

by Allen Wyatt
(last updated January 27, 2017)

6

Zelda would like to be able to automatically add a blank page at the end of a Word document when that document contains an odd number of pages. She would like this to happen because she produces many separate documents that are combined in Adobe and created as PDFs for double-sided printing.

There are two things you can try to get the desired extra page. The first (and perhaps the easiest) is to add a field code to the end of your document that adds the extra page, but only if there are an odd number of pages in the document. Here's the field code:

{ IF { =MOD({ PAGE \* ARABIC}, 2)} = 0 "" "<page break>" }

This should be placed immediately after the last paragraph at the very end of the document. You create the field braces by using Ctrl+F9, and where you see <page break> you should actually add a page break by pressing Ctrl+Enter. The field only adds the page break if the page on which the field occurs is an odd page number. This approach (using the field) is very similar to the approach discussed on this page at the Word MVP site:

http://wordmvp.com/FAQs/TblsFldsFms/InsEvnPgEndChap.htm

The other approach is to use a macro to add the extra page. This doesn't have to be a fancy macro; something as simple as the following will do:

Sub AddPageIfOddNumberOfPages()
If ActiveDocument.BuiltInDocumentProperties("number of pages") Mod 2 <> 0 Then
    Selection.EndKey Unit:=wdStory
    Selection.InsertBreak Type:=wdSectionBreakNextPage
End If
End Sub

Of course, this macro should only be run a single time, just before you print the document for the first time.

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 (13150) applies to Microsoft Word 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Word here: Making Sure a Document Always Has an Even Number of Pages.

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

Using the GotoButton Field

Need to jump from one place in your document to another? One way to do this is through the user of the GotoButton field, ...

Discover More

Inserting and Deleting Rows in a Protected Worksheet

You've protected and saved your worksheet with explicit instructions that you be allowed to insert and delete rows. But ...

Discover More

Retrieving Web Query Data without Interruption

If you use Excel's Web Query tools to grab data from a website, you may run into some problems if the site isn't ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (ribbon)

Changing Sections

When you divide your document into sections in order to change page layout attributes, you need to give some thought to ...

Discover More

Understanding Mirror Margins

Rather than have the margins of your documents always be the same, you can use what Word calls "mirror margins." Here's ...

Discover More

Making a Customized Theme Available to Others

Microsoft Office applications (including Word) allow you to work with collections of common formatting specifications, ...

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}] 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 3 + 2?

2018-04-11 19:09:08

Ken

When a document is opened it is repaginated. Hence the Selection.goto statement should be placed as follows:

Selection.GoTo What:=wdGoToBookmark, Name:="\EndOfDoc"
If ActiveDocument.BuiltInDocumentProperties("number of pages") Mod 2 <> 0 Then


2018-04-11 11:06:52

Ken Endacott

G

After track changes and/or deletion of text then Word repaginates. If you immediately execute the remainder of the macro then the repagination may not have finished and wrong page counts ensue. Stepping through introduces a time delay allowing repagination to conclude.

The solution is to execute at an appropriate place in the macro the statement:

Selection.GoTo What:=wdGoToBookmark, Name:="\EndOfDoc"

Word suspends execution of this statement until repagination is complete.


2018-04-10 10:20:19

G

Ken

I have placed the code in the specified location, but it gives undesirable output when the macro is executed outright. It does seem to function as intended when it is stepped through though. It seems to, in my test documents, spill over to an odd numbered page in some cases when executed.

My documents do usually have tracked changed and hidden text, but I have turned all of that off prior to checking the page count and converting to PDF. I added an additional code to delete hidden text prior to page count and conversion.

Any suggestions on this?

Thanks


2018-04-05 06:15:23

Ken

G
The four statements from within the AddPageIfOddNumberOfPages macro should be placed immediately before the CONVERT PDF comment.


2018-04-04 12:36:46

G

I have a batch conversion Word to PDF macro I am working with that I would like to nest this even page functionality into some kind of way. I'd prefer it to be part of the overall sub and not a separate sub, if possible. However, when I try to insert it into my routine, it fails to do anything since it is looking for the properties of the active document. I presume this has something to do with the placement of the if statement within my batch conversion since the document is not technically always "active", but I can't seems to get it working properly. Below is my original conversion macro. How would I be able to incorporate getting my document to verify and correct to an even number of pages during the batch process using the macro in the original article/post. If it matters, I'm using Word 2013. Also, I have a specific need to do this with a macro in lieu of a field code. Thanks!


Sub BatchPDF_Default()

Dim strFilename As String
Dim strDocName As String
Dim strPath As String
Dim oDoc As Document
Dim fDialog As FileDialog
Dim intPos As Integer
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Select folder containing the Word files you want to convert and click Ok."
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled", , "List Folder Contents"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(strPath, 1) = Chr(34) Then
strPath = Mid(strPath, 2, Len(strPath) - 2)
End If
strFilename = Dir$(strPath & "*.doc")
While Len(strFilename) <> 0
Set oDoc = Documents.Open(strPath & strFilename)
strDocName = ActiveDocument.FullName
intPos = InStrRev(strDocName, ".")
strDocName = Left(strDocName, intPos - 1)

'TURN OFF MARKUPS
ActiveDocument.ShowRevisions = False

'CONVERT PDF
strDocName = strDocName & ".pdf"
oDoc.SaveAs Filename:=strDocName, _
FileFormat:=wdFormatPDF

oDoc.Close SaveChanges:=wdDoNotSaveChanges
strFilename = Dir$()
Wend
End Sub


2015-07-21 17:03:50

Gloria

Hi Allen,

The field code (the first one in your article) did not work for me. I got an "Error! Unknown switch argument" for the field value (and no ending even page). I tried this in Word 7 on Win. 8.1 and Word 10 on Win. 7. I also tried the example file (with field) on the MVP site, and that did not work, either. However, the macro worked just fine. It's now part of my Normal template. Thanks for the help.


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.

Newest Tips
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.