Windows 7 - Different Header/Footer on every page of a document

Asked By BC on 09-Sep-08 09:31 AM
PC running Win 2k and MS Word 2003.

I am fairly familiar with using multiple sections within technical documents
to display different page numbering styles, layouts, formats, etc., but I
have come across a situation that I don't know how exactly to handle.
Occasionally, I need to be able to have a different Header/Footer on every
page of a document.

I realize that ordinarily this would be a crazy thing to attempt but, while
this situation does not happen often, it is a possibility (see pages 5 and 6
in the following PDF:
directly related to the later half of the following statement from page 6,
classification level of information contained on that page."

The only "solution" that I have been able to come up with is to use a new
section for every page, but this seems to be unnecessarily cumbersome. Is
there an easier way to accomplish this?


l replied on 09-Sep-08 10:00 AM
I am not sure I know enough about your document to come up with a solution.
However, I am wondering whether you could use STYLEREF fields in the header.
A STYLEREF field can pick up the contents of text formatted with a specific
style. If the information you need to show to the header is found directly on
the page, you could format the text with a special style made for that
purpose and make the STYLEREF field pick up the text.

A STYLEREF field inserted in a header (or footer) prints the first (or last)
text formatted with the specified style on the current page. The field is
automatically updated whenever you change the text in the document. If no
text formatted with the style in question is found on a page, the STYLEREF
field repeats the same text on all subsequent pages until another occurrence
of the specified style is found.

For further details about the STYLEREF field, search for “Field codes:
StyleRef field” in the online help of Word. See also this article:

See this article for tips on different ways to repeat data:

Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
Document automation - add-ins, macros and templates for Microsoft Word
BC replied on 09-Sep-08 11:00 AM
Thanks for the quick response.

I just tried your suggestion - I like the idea, however, I don't believe
that will work out quite right for me.

I'm not very familiar with fields in Word (other than the basic page
numbering, captions, cross-references, footnotes, and TOC), but based on the
information you provided and my quick experiment, using the STYLEREF would
require that the classification indicator (i.e. the (U), (X), (Y), and (Z))
to be its own style because it can only display the contents of a selected
style. In this case, probably a Heading style of some sort. This would
necessitate that an in-line heading be used (doable, but not very user
friendly when composing a long document).

My preference is to setup four different styles. The "parent" style would be
Normal (or Body Text) and the "children" would be:
Normal – (U)
Normal – (X)
Normal – (Y)
Normal – (Z)

Each of these styles would be exactly the same as the "parent" except for
the addition of a numbering prefix of (U), (X), (Y), or (Z) respectively.
With this particular setup, STYLEREF gives me the contents of the paragraph
rather than the classification level.

Additionally, the STYLEREF seems to only give the ability to find the first
or last occurrence of a particular style whereas I need to find the "highest
level" used. That is, (U) < (X) < (Y) < (Z).

I need something more along the lines of:

If "Normal - (Z)" was used on this page, then display "Z" else
If "Normal - (Y)" was used on this page, then display "Y" else
If "Normal - (X)" was used on this page, then display "X" else display "U"

I noticed an IF field on the Insert > Field… dialog – can something like the
above be achieved using this type of field? Macros and automated code are
frowned upon and automatically blocked.

Suzanne S. Barnhill replied on 09-Sep-08 11:57 AM
It may well be possible to do this with nested IF fields. The condition is
the tricky part, unfortunately. If there were no paragraphs of the
designated style in the document at all, you could test against the error
message ("Error! No text of specified style in document."), but the StyleRef
field will not display this field based on text on a given page.

Consequently, a separate section for each page may be the only way to
achieve what you want.

Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
MalcolmPatterso replied on 11-Sep-08 04:30 PM
The need to perform this kind of action is common to a wide variety of users,
whether they are associated with security classification (DOD, DOE, DHS,
etc.) or proprietary information in the private sector.

In general, the attribute would attach to text (not to paragraphs, pages,
sections, or chapters). More than one attribute may apply, and overlap must
be supported. It may be necessary to calculate a value for one or more of
these higher-level groupings. In the present case, it would be a calculated
value for the page, since the marking of the page would depend on multiple
snippets of text.

It would be an important benefit if this attribute could be
semi-permanent--protected by the signature key of a classifying official.
Retaining the attribute as the data is copied from one document to another
would dramatically reduce the potential for inadvertant release.