PAGEREF in an IF statement in a header or footer when printing

G

Giles

My page footers need to include references to a range of pages x-y, and need
to state "... on pages x to y" or "... on page x" depending upon whether the
range is several pages or a single page.

I can achieve this using the IF statement and testing bookmarks:
{IF {PAGEREF pageref001} <> {PAGEREF pageref002} "pages {PAGEREF pageref001}
to {PAGEREF pageref002}" "page {PAGEREF pageref001}"}

This works perfectly well in the body of the page. If it is in the header or
footer then it works fine on screen; and it works fine if you print in
reverse order; but if you print without the reverse order option then it only
works if the bookmarks occur earlier in the document. If the pageref refers
to a bookmark later than the current page (by which I mean the page on which
the pageref statement appears), the current page number seems to be used
instead.

It happens with Word 2003 and Windows XP, and I have produced a test
document that demonstrates it.
 
C

Cindy M.

Hi Giles,

I think the field was designed to be used in the document body and the behavior
is probably "by design" (IOW it wasn't designed to be used like a StyleRef
field in the headers/footers). I suspect that this has with the order in which
fields are updated, and whether Word is storing any update information for use
when calculating the fields.

If you want to email me a copy of your test document I can test it in Office
2007 and submit it as a suggestion to MS for a future version if the behavior
still exists (it's much too late in the release cycle to make such a significant
change for 2007).
My page footers need to include references to a range of pages x-y, and need
to state "... on pages x to y" or "... on page x" depending upon whether the
range is several pages or a single page.

I can achieve this using the IF statement and testing bookmarks:
{IF {PAGEREF pageref001} <> {PAGEREF pageref002} "pages {PAGEREF pageref001}
to {PAGEREF pageref002}" "page {PAGEREF pageref001}"}

This works perfectly well in the body of the page. If it is in the header or
footer then it works fine on screen; and it works fine if you print in
reverse order; but if you print without the reverse order option then it only
works if the bookmarks occur earlier in the document. If the pageref refers
to a bookmark later than the current page (by which I mean the page on which
the pageref statement appears), the current page number seems to be used
instead.

It happens with Word 2003 and Windows XP, and I have produced a test
document that demonstrates it.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
R

Robert M. Franz (RMF)

Hi all
I think the field was designed to be used in the document body and the behavior
is probably "by design" (IOW it wasn't designed to be used like a StyleRef
field in the headers/footers). I suspect that this has with the order in which
fields are updated, and whether Word is storing any update information for use
when calculating the fields. [..]
My page footers need to include references to a range of pages x-y, and need
to state "... on pages x to y" or "... on page x" depending upon whether the
range is several pages or a single page.

I can achieve this using the IF statement and testing bookmarks:
{IF {PAGEREF pageref001} <> {PAGEREF pageref002} "pages {PAGEREF pageref001}
to {PAGEREF pageref002}" "page {PAGEREF pageref001}"}

This works perfectly well in the body of the page. If it is in the header or
footer then it works fine on screen; and it works fine if you print in
reverse order; but if you print without the reverse order option then it only
works if the bookmarks occur earlier in the document. If the pageref refers
to a bookmark later than the current page (by which I mean the page on which
the pageref statement appears), the current page number seems to be used
instead.

thinking aloud here: there is a compatibility option (Tools | Options |
Compatibility: "Print body text before header/footer") you could play
with to see whether this helps.

Additionally, you could try to put the IF field into the body and use
SET in one case to set a custom document property. In the header, you
can test this property with another IF and act accordingly.

0.2cents
Robert
 
G

Giles

Hi Robert, the compatibility option didn't help but your suggestion of using
SET seems to be one that I can work with. I can create a bookmark called
pages1to2 and assign it at the top of the document with my IF statement, and
then the page headers and footers need only to refer to a simple bookmark
with a REF instruction. That seems to work nicely, and fingers crossed it
will continue to do so when I apply it in my application.

For interest, the fault seems to be with the IF command, because I also
tried an alternative in which I assigned separate bookmarks with each of the
page references and then used "{IF {REF ..." to access them, but that didn't
seem to work.

Many thanks for your suggestion.
Giles

PS Cindy, thanks for your offer, I'll send you the test document including
the test of Robert's suggestion to try out.



--
Giles


Robert M. Franz (RMF) said:
Hi all
I think the field was designed to be used in the document body and the behavior
is probably "by design" (IOW it wasn't designed to be used like a StyleRef
field in the headers/footers). I suspect that this has with the order in which
fields are updated, and whether Word is storing any update information for use
when calculating the fields. [..]
My page footers need to include references to a range of pages x-y, and need
to state "... on pages x to y" or "... on page x" depending upon whether the
range is several pages or a single page.

I can achieve this using the IF statement and testing bookmarks:
{IF {PAGEREF pageref001} <> {PAGEREF pageref002} "pages {PAGEREF pageref001}
to {PAGEREF pageref002}" "page {PAGEREF pageref001}"}

This works perfectly well in the body of the page. If it is in the header or
footer then it works fine on screen; and it works fine if you print in
reverse order; but if you print without the reverse order option then it only
works if the bookmarks occur earlier in the document. If the pageref refers
to a bookmark later than the current page (by which I mean the page on which
the pageref statement appears), the current page number seems to be used
instead.

thinking aloud here: there is a compatibility option (Tools | Options |
Compatibility: "Print body text before header/footer") you could play
with to see whether this helps.

Additionally, you could try to put the IF field into the body and use
SET in one case to set a custom document property. In the header, you
can test this property with another IF and act accordingly.

0.2cents
Robert
--
/"\ ASCII Ribbon Campaign | MS
\ / | MVP
X Against HTML | for
/ \ in e-mail & news | Word
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top