file name autotext in footer update when name changed

G

Guest

Hi,

I use the file name autotext in the footer -- is there a way to have that
footer automatically update when we change the name of the document.

When we update sales material we put a new date after the file name. It
would be nice to be able to do a file/save as and have the footer update with
the new file name.

Thanks,
 
J

Jay Freedman

Add this macro to the template for the document (see
http://www.gmayor.com/installing_macro.htm if needed):

Sub FileSaveAs()
Dim oldOption As Boolean

oldOption = Options.UpdateFieldsAtPrint
Options.UpdateFieldsAtPrint = True

If Dialogs(wdDialogFileSaveAs).Show = -1 Then
Application.ScreenUpdating = False
' update all fields
With ActiveDocument
.PrintPreview
.ClosePrintPreview
.Saved = False
.Save
End With
Application.ScreenUpdating = True
End If

Options.UpdateFieldsAtPrint = oldOption
End Sub

It uses the fact that if the "Update fields" box is checked in the
Tools > Options > Print dialog, then switching to the Print Preview
will update all the fields in the document, including the filename
field. The macro makes sure that option is set. Then it shows the Save
As dialog; if you click the OK button, the macro quickly switches to
Print Preview and back again, and then saves again so the updated
fields are written to the disk file.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
G

Guest

Suzanne -- thank you for your help! I thought that the file name use to
update -- since I am now using Word 2002 and 2003 this explains why that no
longer happens.

I put in the suggested macron on one of my documents and it worked like a
charm. I assume I can do a "global" macro so all my word docs update.

Thanks! Bev
 

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