0
votes

I am preparing a board report for my boss. It has 10 different sections.

She wants in the header the page number of the current page in the whole document and its page number within it section.

So for example if: * the whole document has 25 pages and * section "XYZ" has 3 pages and starts on the 10th page of the document

then the header for the first page of XYZ would read:

Report Page 10 of 25 - XYZ Page 1 of 3

The header for the second page of XYZ would be:

Report Page 11 of 25 - XYZ Page 2 of 3

Is this possible? I have failed so far!

1

1 Answers

1
votes

Your question really has nothing to do with VBA, but everything to do with field coding. Furthermore the field coding for what you want is relatively complex, as Word doesn't natively support dual numbering schemes. The 'Page X of Y' aspect for the document as a whole is quite easily obtained via Word's PAGE and NUMPAGES fields, and the 'Y' part of the 'Page X of Y' aspect for a given Section is equally easily obtained via a SECTIONPAGES field. For the first Section, a simple PAGE field can also be used for the 'X' part. It's for subsequent Sections that getting the 'X' part for a Section becomes complicated. The first thing you'll need to do is to unlink each Section's header from the one preceding it. Then add a field coded as:

{SET Sctn# {SECTIONPAGES}}

in each Section's header except the last, where # is the Section number. Then, in each subsequent Section's header, you'll need a formula field like:

{={PAGE}-Sctn1}

for the 'X' part in Section 2:

{={PAGE}-Sctn1-Sctn2}

for the 'X' part in Section 3, and so on.

Note: The field brace pairs (i.e. '{ }') for the above examples are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues.