Re: Two series of page numbers in the same document
- From: Pesach Shelnitz <pesach18(AT)hotmail.com>
- Date: Wed, 12 Aug 2009 00:36:03 -0700
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.
- Follow-Ups:
- Re: Two series of page numbers in the same document
- From: Peter Jamieson
- Re: Two series of page numbers in the same document
- References:
- Two series of page numbers in the same document
- From: George-the-cat
- Re: Two series of page numbers in the same document
- From: Peter Jamieson
- Two series of page numbers in the same document
- Prev by Date: Re: GetOpenFilename problem
- Next by Date: RE: wdAdjustFirstColumn [Word 2003]
- Previous by thread: Re: Two series of page numbers in the same document
- Next by thread: Re: Two series of page numbers in the same document
- Index(es):
Relevant Pages
|