Re: Two series of page numbers in the same document

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

Peter is correct. I managed to confuse myself with my own faulty testing. I
apologize for the confusion.

There is, however, a much simpler way to achieve the desired page numbering
without the need for a macro.
1) Create a bookmark at the very beginning of each section. For this
example, let's call them StartSec1, StartSec2, etc.
2) Create the following field codes and text in the header for Section 2.
Page {={PAGE} - {PAGEREF StartSec2} + 1} of {SECTIONPAGES} pages in
Section {SECTION}
To do this create the PAGE, PAGEREF, SECTIONPAGES, and SECTION fields in
the
usual way. Then select ={PAGE} - {PAGEREF StartSec2} + 1 and press CTRL+F9.
3) Create similar field codes and text with the appropriate bookmark in the
other sections.
After you see how this works, you can modify the headers as you please.

--
Hope this helps,
Pesach Shelnitz


"Peter Jamieson" wrote:

Unfortunately although there are { SECTION } and { SECTIONPAGES }
fields, the first just inserts the section number and the second inserts
the total number of pages in the section - there is no field that's the
equivalent of { PAGE } within a section.

Although It looks as if it ought to be feasible to calculate the "page
within section" number using fields in the header, I've never been able
to make it work - at some point, Word seems "unsure" about which section
it is dealing with and behaves rather oddly. Perhaps someone else can
manage it.

So IMO you have to use a macro to do it, and run it prior to printing.
The following scheme seems to work:

In your header, use the nested field

{ ={ PAGE }-{ DOCVARIABLE "SOFAR{ SECTION }" } }

(or if you prefer to reduce space

{={PAGE}-{DOCVARIABLE "SOFAR{SECTION}"}}

)

Each pair of {} needs to be the special Field code braces that you can
insert using ctrl-F9

Use the following macro to repopulate the Document Variables required by
the DOCVARIABLE field.

Sub UpdateSectionPageTotals()
Const strTotalSoFar As String = "SOFAR"
Dim objSection As Word.Section
Dim objVariable As Word.Variable
For Each objVariable In ActiveDocument.Variables
If Left(objVariable.Name, Len(strTotalSoFar)) = strTotalSoFar Then
objVariable.Delete
End If
Next
ActiveDocument.Variables.Add strTotalSoFar & "1", 0
For Each objSection In ActiveDocument.Sections
ActiveDocument.Variables.Add "SOFAR" & CStr(objSection.Index + 1),
objSection.Range.Information(wdActiveEndPageNumber)
' Debug.Print CStr(objSection.Index) + 1,
'objSection.Range.Information(wdActiveEndPageNumber)
Next
End Sub

Peter Jamieson

http://tips.pjmsn.me.uk

George-the-cat wrote:
Hi. Is there a way to have two sets of page numbers in the same document?
We need one running page number that is the page numbering for the entire
document, and one that is the page numbering for each section. For example,
if I'm in Section 4, I need to show that it's page 95 of the entire document
but only page 6 of Section 4.
Thank you.

We're using Word 2007 and Excel 2007.

.



Relevant Pages

  • Re: Repayment of an overpayment of Working Tax Credit
    ... the country uses is a good opportunity to insult me - shows how ... I see you won't give any indication of your employment or education. ... It is wrong because it confused poor Peter. ... realise again that would confuse somebody like you Peter. ...
    (uk.finance)
  • Re: Ping P strauss!
    ... publish someones email address on a public forum such as this ... because what's in his email header is a bogus address. ... Peter used his real address. ...
    (rec.sport.golf)
  • Re: Stopping the page numbering in the middle of a document.
    ... As both Peter and Idaho said, you must be in the header for the first ... numbering without deleting the numbering on the previous pages. ...
    (microsoft.public.word.docmanagement)
  • Re: Font Change/Mail Merge/Labesl
    ... Excellent, Peter. ... The curly braces are special "field code braces - you can't type them on the ... If you can't see the field codes easily because they are in a table cell, ... I would like to be able to put the "last name" in bold. ...
    (microsoft.public.word.mailmerge.fields)