Page Number and Field Codes

B

Bruce

Many times my documents will start at a number other than
1. I would like the total pages or "{NUMPAGES}" to update
appropriately. Words "Help" section stated the following:

If the page numbering starts on a page number other than
1, use an = (Formula) field to compute the total page
number count. To determine the starting page number for
the active document, (StartingNumber), click Page Numbers
on the Insert menu, and then click Format.

Page { PAGE } of { = (StartingNumber - 1) + { NUMPAGES } }

But when I try this I get the following error:

"!Undefined Bookmark, STARTINGN"

I know I'm probably forgetting something very basic but
this is driving me crazy.

Thanks in advance.
 
S

Suzanne S. Barnhill

You have to type in the actual starting page number *or* you have to place a
bookmark named "StartingNumber" on the first page of the document.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
B

Bruce

Suzanne,

Thanks for the reply but I'm not too sure what you mean by
this. I'm trying to understand that if I use a bookmark
how will it update each page? I thought the bookmark
would be static. It must be mental block but I'm trying
to decipher how each page will be updated accordingly. I
don't know if this helps but I used the Page x of y in the
header to automatically number the pages.

Presently, I use vba to prompt for a starting page
number. In a With End With section the following code is
used to grab the starting page number.

..Sections(1).Headers
(wdHeaderFooterPrimary).PageNumbers.StartingNumber = Val
(frmHeader.txtStartingPageNo.Text)

The starting page number appears to work properly. Could I
use a variable or does it have to be a bookmark? If so,
then how because I keep getting an syntax error. If you
could give me an example I would appreciate it. I'm sort
of a "visual" person. Thanks again.

Bruce
 
S

Suzanne S. Barnhill

The bookmark is only part of the calculation; you are adding the page number
of that bookmark to the NumPages field, which returns the number of pages in
the document, without reference to the starting page number. In order to
make it match the page number on the last page, you can either use a
calculated field (as you are doing), or you can put a bookmark on the last
page and include a cross-reference to the page number of that bookmark.
Alternatively, if your code were to write the starting page number to a
document property, then you could use a DocProperty field to include it in
your calculated field.

For more specific details, you might want to post in the
microsoft.public.word.vba.userforms NG.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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