View Single Post
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default What field shows "ThisPage of ThisSection"?

Hi Ed,

Word doesn't have a field for returning each page# for a given Section. However, you could use the following field code in the
header or footer:
{QUOTE{IF{PAGE}= 1 {SET Section0 0}}{IF{PAGE}={NUMPAGES} "Last Page" {IF{={SECTIONPAGES}+{REF {QUOTE Section{={SECTION}-1}}}}={PAGE}
"{SET {QUOTE Section{SECTION}} {PAGE}}Last Page" {IF{={PAGE}-{REF {QUOTE Section{={SECTION}-1}}}}= 1 "First Page" "Other Page"}}}}

How this works:
The field creates a series of bookmarks named Section# (where # is the Section number) and assigns the corresponding Section's
SECTIONPAGES count to them. The code to do this is {SET {QUOTE Section{SECTION}} {PAGE}}, and is only executed on the last page of
each Section.
The code then deducts the previous Section's page count from the current page number to determine the current Section page#.
If the current Section page# equals the Section page count, 'Last Page' is displayed; otherwise if the current Section page# equals
1, 'First Page' is displayed; otherwise 'Other Page' is displayed.
The {SET Section0 0} field is needed on the first page of the document because there's no Section 0 and the code would generate an
error without it
The IF{PAGE}={NUMPAGES} test is needed to prevent the code adding an unwanted bookmark for the last Section; otherwise the output
for the last Section becomes unstable.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"Ed from AZ" wrote in message ...
I am trying to set up an IF field in Word 2003. It needs to say:
"IF this is Page 1 of ThisSection, "THIS", IF this is LastPage of
ThisSection, "THAT", "OTHER"

But I'm having difficulty finding a field (or combination thereof?)
that will give me the page number of the section I'm in.

A drop-kick in the right direction would be appreciated.

Ed