Update footer Fields

J

John

Hi,

I have the following Field in the footer of a template. It updates fine when
printed but I am trying to get it to update when I do a FileSaveAs.

{FILENAME \* Lower \* MERGEFORMAT }{if{numpages}>{page}" /more"}

I have included some code to update these fields and the FILENAME updates
OK, but the second part doesn't.

Sub FileSaveAs()
For Each pRange In ActiveDocument.StoryRanges
Do
For Each oFld In pRange.Fields
oFld.Update
Next oFld
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
End Sub

Any suggestions what I can do to make the second part update?

Thanks,

John
 
G

Graham Mayor

Assuming the second part is actually a field and not merely typed from the
keyboard then try

Options.UpdateFieldsAtPrint = True
Application.ScreenUpdating = False
PrintPreview = True
PrintPreview = False
ActiveDocument.ActiveWindow.View.Type = wdPrintView
Application.ScreenUpdating = True

or

Dim oField As Field
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oFooter As HeaderFooter

For Each oSection In ActiveDocument.Sections
For Each oHeader In oSection.Headers
If oHeader.Exists Then
For Each oField In oHeader.Range.Fields
oField.Update
Next oField
End If
Next oHeader
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
oField.Update
Next oField
End If
Next oFooter
Next oSection


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

John

Thanks for that. Unfortunately, PrintPreview doesn't update this particular
field. If I use PrintPreview from the File menu it stays the same. It's only
when I actually Print the document that it updates. Unfortunately, these
documents are normally emailed and therefor seldom printed.

John
 
G

Graham Mayor

Did you try the second option?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Charles Kenyon

http://gregmaxey.mvps.org/File_Name_And_Path.htm.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
J

John

Yes I did. It updates the Filename OK but not the second field which should
result in " /more" when the document is more than 1 page long.

John
 
J

John

Thanks for the link. That is the example I used and resulted in the problem
i'm having.

John
 
G

Graham Mayor

Somewhat baffled as here that field combination updates itself without
external updating. Only the filename field requires a forced update. Had you
not said that it works if you print the document, I would have concluded
that you had not entered a field combination but merely typed it as shown in
the post. Just to be absolutely sure we are singing from the same hymn
sheet, I take it you did insert the fields using CTRL+F9 for the field
boundaries?

I'd ask you to send the document, but I am in the process of relocating and
I am currently working with a very slow and expensive temporary dial-up
connection.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Charles Kenyon

That link has the code to force updates of this field. Did you go through
the entire article rather than just insert the field?
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

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