From: Vesna on
Doug,

Thanks for the reminder about the primary header vs. the first and second
page headers. I tried a number of different things. It does not work as I'd
like. Unless I'm not doing something right, I can get page 1 to (1) always
have no number or (2) always be numbered 1.

I only want a page number on page 1 if there is more than one page.

I believe I need to use the IF formula to accomplish that. In that case, I
need to know how to refresh the page-related field codes in the header
without resorting to flipping the document to Print Preview and back.

Let me know if you need any other info. Thanks!

--
Vesna


"Doug Robbins - Word MVP" wrote:

> Use the Different First Page option and put the page number in the Primary
> Header/Footer and leave it out of the First Page Header/Footer.
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>
> "Vesna" <ajdeigrajkolo(a)kvs1985.us> wrote in message
> news:19FD2C59-6DF3-446C-AF30-5628C0DD6CF5(a)microsoft.com...
> > Hello!
> >
> > I am working on a Word 2003 template with the following:
> >
> > - the page header includes the following fields:
> > { IF {NUMPAGES \* MERGEFORMAT } = 1 “” { PAGE \* MERGEFORMAT } \*
> > MERGEFORMAT }
> > - the body has a FORMTEXT form field plus a table of FORMTEXT form fields
> > - the footer has {FILENAME} and {SAVEDATE}
> > - the body has no specific sections defined
> >
> > I worked on similar templates about 10 yrs. ago and got around the field
> > and
> > form field refresh/update problems by flipping to a print preview then
> > back
> > to force both the page and file info fields to refresh. That was a very
> > tacky
> > looking solution user-presentation-wise. This time, I created
> > UpdateAllFields() to update all of the field and form fields. Essentially,
> > if
> > it was a successful save, I update the fields, then resave so everything
> > is
> > current. PROBLEM: This updates everything EXCEPT the page info fields.
> >
> > I want the true page numbers reflected when a person saves, saves as, and
> > reopens the doc. The desired effect is no page number on page 1 if there
> > is
> > only one page, otherwise show a page number on every page, but the problem
> > can be simplified even further. Even a plain page number on page 1 isn't
> > accurately reflected when the doc goes from 2 pages down to 1 and is
> > saved/saved as, then reopened.
> >
> > I've spent the last day pouring over knowledge base articles, Word 2003
> > Help, and this community boning up on the object model and looking for an
> > easy-to-comprehend and tasteful solution. All I've become is more
> > confused.
> >
> > What code can I add to UpdateAllFields() to refresh the page info fields
> > so
> > they are saved correctly in doc's built with this template? Am I stuck
> > flipping to a print preview, then back, then resaving?
> >
> > I've included my FileSave(), FileSaveAs(), and UpdateAllFields() for your
> > reference. ANY help or suggestions would be appreciated. Thank you in
> > advance!
> >
> > Vesna
> >
> > Sub FileSave()
> > ' FileSave Macro - Saves the active document or template
> > On Error GoTo FileSave_error
> > ActiveDocument.Save ' File, Save
> > ' if user completed File, Save or ctrl+S action
> > ' force refresh of all fields, including those in header & footer
> > UpdateAllFields
> > ' force resave so header and footer updates are also saved
> > ActiveDocument.Save
> > Exit Sub
> > FileSave_error:
> > ' if user DIDN'T complete File, Save or ctrl+S action
> > ' or other error encountered
> > Exit Sub
> > End Sub
> >
> > Sub FileSaveAs()
> > ' FileSaveAs Macro - Saves a copy of the document in a separate file
> > Dim retval As Integer
> > retval = Dialogs(wdDialogFileSaveAs).Show ' File, Save As...
> > If retval = -1 Then ' if dialog box closed with OK
> > ' force refresh of all fields, including those in header & footer
> > UpdateAllFields
> > ' force resave so updates are also saved
> > ActiveDocument.Save
> > End If
> > End Sub
> >
> > Sub UpdateAllFields()
> > ' update all fields
> > Dim aStory As Range
> > Dim aField As Field
> > For Each aStory In ActiveDocument.StoryRanges
> > For Each aField In aStory.Fields
> > aField.Update
> > Next aField
> > Next aStory
> >
> > ' update page numbers
> > ' CODE IS NEEDED HERE!!!!
> >
> > End Sub
> >
> > --
> > Vesna
>
From: Doug Robbins - Word MVP on
If you want the page number to only appear on page one if there is more than
one page, then use the following field construction

{ IF { NUMPAGES } > 1 { PAGE } }

You must use Ctrl+F9 to insert each pair of field delimiters and Alt+F9 to
toggle off their display.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Vesna" <ajdeigrajkolo(a)kvs1985.us> wrote in message
news:1ECDA84F-EA67-4994-AE0D-BD4DB28CCE2F(a)microsoft.com...
> Doug,
>
> Thanks for the reminder about the primary header vs. the first and second
> page headers. I tried a number of different things. It does not work as
> I'd
> like. Unless I'm not doing something right, I can get page 1 to (1) always
> have no number or (2) always be numbered 1.
>
> I only want a page number on page 1 if there is more than one page.
>
> I believe I need to use the IF formula to accomplish that. In that case, I
> need to know how to refresh the page-related field codes in the header
> without resorting to flipping the document to Print Preview and back.
>
> Let me know if you need any other info. Thanks!
>
> --
> Vesna
>
>
> "Doug Robbins - Word MVP" wrote:
>
>> Use the Different First Page option and put the page number in the
>> Primary
>> Header/Footer and leave it out of the First Page Header/Footer.
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>>
>> "Vesna" <ajdeigrajkolo(a)kvs1985.us> wrote in message
>> news:19FD2C59-6DF3-446C-AF30-5628C0DD6CF5(a)microsoft.com...
>> > Hello!
>> >
>> > I am working on a Word 2003 template with the following:
>> >
>> > - the page header includes the following fields:
>> > { IF {NUMPAGES \* MERGEFORMAT } = 1 “” { PAGE \* MERGEFORMAT } \*
>> > MERGEFORMAT }
>> > - the body has a FORMTEXT form field plus a table of FORMTEXT form
>> > fields
>> > - the footer has {FILENAME} and {SAVEDATE}
>> > - the body has no specific sections defined
>> >
>> > I worked on similar templates about 10 yrs. ago and got around the
>> > field
>> > and
>> > form field refresh/update problems by flipping to a print preview then
>> > back
>> > to force both the page and file info fields to refresh. That was a very
>> > tacky
>> > looking solution user-presentation-wise. This time, I created
>> > UpdateAllFields() to update all of the field and form fields.
>> > Essentially,
>> > if
>> > it was a successful save, I update the fields, then resave so
>> > everything
>> > is
>> > current. PROBLEM: This updates everything EXCEPT the page info fields.
>> >
>> > I want the true page numbers reflected when a person saves, saves as,
>> > and
>> > reopens the doc. The desired effect is no page number on page 1 if
>> > there
>> > is
>> > only one page, otherwise show a page number on every page, but the
>> > problem
>> > can be simplified even further. Even a plain page number on page 1 isn't
>> > accurately reflected when the doc goes from 2 pages down to 1 and is
>> > saved/saved as, then reopened.
>> >
>> > I've spent the last day pouring over knowledge base articles, Word 2003
>> > Help, and this community boning up on the object model and looking for
>> > an
>> > easy-to-comprehend and tasteful solution. All I've become is more
>> > confused.
>> >
>> > What code can I add to UpdateAllFields() to refresh the page info
>> > fields
>> > so
>> > they are saved correctly in doc's built with this template? Am I stuck
>> > flipping to a print preview, then back, then resaving?
>> >
>> > I've included my FileSave(), FileSaveAs(), and UpdateAllFields() for
>> > your
>> > reference. ANY help or suggestions would be appreciated. Thank you in
>> > advance!
>> >
>> > Vesna
>> >
>> > Sub FileSave()
>> > ' FileSave Macro - Saves the active document or template
>> > On Error GoTo FileSave_error
>> > ActiveDocument.Save ' File, Save
>> > ' if user completed File, Save or ctrl+S action
>> > ' force refresh of all fields, including those in header & footer
>> > UpdateAllFields
>> > ' force resave so header and footer updates are also saved
>> > ActiveDocument.Save
>> > Exit Sub
>> > FileSave_error:
>> > ' if user DIDN'T complete File, Save or ctrl+S action
>> > ' or other error encountered
>> > Exit Sub
>> > End Sub
>> >
>> > Sub FileSaveAs()
>> > ' FileSaveAs Macro - Saves a copy of the document in a separate file
>> > Dim retval As Integer
>> > retval = Dialogs(wdDialogFileSaveAs).Show ' File, Save As...
>> > If retval = -1 Then ' if dialog box closed with OK
>> > ' force refresh of all fields, including those in header &
>> > footer
>> > UpdateAllFields
>> > ' force resave so updates are also saved
>> > ActiveDocument.Save
>> > End If
>> > End Sub
>> >
>> > Sub UpdateAllFields()
>> > ' update all fields
>> > Dim aStory As Range
>> > Dim aField As Field
>> > For Each aStory In ActiveDocument.StoryRanges
>> > For Each aField In aStory.Fields
>> > aField.Update
>> > Next aField
>> > Next aStory
>> >
>> > ' update page numbers
>> > ' CODE IS NEEDED HERE!!!!
>> >
>> > End Sub
>> >
>> > --
>> > Vesna
>>