Word: Difficulty processing fields in the footer during printing

Once again, a forum discussion has brought to light something new and useful to know when working professionally with Word.

When someone asks how to display different content in the footer for the last page, only, the recommended approach since time immemorial is to use an IF field. The If field tests whether the current page number is also the last page number. When that’s the case, different content is displayed. Basic instructions on how to set this up can be found on the Word MVPs FAQ site. It’s not always simple to set up, but it works.

Except in this case, it didn’t… But only when printing the document using the object model. Using the PrintOut method, or even triggering printing via ExecuteMso(“FileQuickPrint”) resulted in the last three pages showing no footer. When printed using the commands in Word’s user interface, there was no problem.

The discussion went back-and-forth for a couple of days, until the person with the problem realized that the area officially provided for the footer content was too small. As soon as the bottom margin of the document was “raised” to the height required for the footer, printing was no problem whatsoever.

On the one hand, Word tries to make life as easy as possible for the user. On the other, Word’s layout engine is required to make extremely complex calculations in order to dynamically “flow” document content on the page, and from page to page. One way Word makes life easier is that it doesn’t require the user to check that the settings in the Page Layout dialog box for the margins, headers and footers logically allow content to appear on the page, without overlap. If the content for a footer requires more space, vertically, than the settings specify, Word silently breaks the document content to a new page in order to accomodate the footer.

Apparently, having to calculate the result of the IF field, plus adapting the page flow to allow display of the result in a space that was not large enough, was more than Word could handle. So it simply stopped printing the footer information at some point.

Increasing the space allowed for the footer, by increasing the bottom margin setting, resolved the issue.



Leave a Reply