View Single Post
  #5   Report Post  
Ian M. Walker
 
Posts: n/a
Default How do I get the filename to auto-update in the header?



"Jay Freedman" wrote:

On Thu, 27 Oct 2005 15:13:03 -0700, "Ian M. Walker"
wrote:

"garfield-n-odie" wrote:

See http://support.microsoft.com/?kbid=832897 "The FILENAME field
does not automatically update when you open a document in Word
2002 or Word 2003".

As for why the Insert AutoText option is grayed out in the Header
and Footer toolbar, this is usually caused by overwriting the
Normal.dot global template with a regular Word document. Try
renaming Normal.dot as described in
http://word.mvps.org/FAQs/AppErrors/...ocNotBlank.htm .

Ian M. Walker wrote:

I can put the filename into headers via the "insert" and "field" menus but
these do not auto-update. The help suggests using the options on the header
and footer menu for auto-updates but for some reason filename is not an
option for me in Word 2003. I'm convinced that I used to use that in my
footers all the time so I don't know why it would be missing in this latest
version. Also, the first menu in headers and footers "Insert auto-text" is
greyed out.

Can anybody help me with the auto-updating of filenames in my header and
also explain why this is missing from the headers and footers menu?

Thank you.

Office 2003 with Windows XP SP2



First of all, thank you very much for taking the time to offer assistance
and point to the documents.

The first response was very interesting and I followed the steps to create
the macro for auto-updating. Unfortunately, I discovered that just as when
you use "select all" and "f9" to update fields, the macro does not include
headers and footers. Do you know enough about visual basic to change that
please?

As for the second part, if I re-create/re-name, etc. my Normal.dot is there
a way to export my current macros to it as I have a fair few for some
technical documents I write.

Thank you again.


Hi Ian,

For the updating of fields in the headers, the macro in the KB article
should work unless you have multiple sections with Same As Previous
turned off. A more comprehensive approach along the same lines is
based on the technique in
http://word.mvps.org/FAQs/MacrosVBA/...AllWithVBA.htm, like
this:

Sub UpdateAllFields()
Dim myStoryRange As Range

For Each myStoryRange In ActiveDocument.StoryRanges
myStoryRange.Fields.Update
Do While Not (myStoryRange.NextStoryRange Is Nothing)
Set myStoryRange = myStoryRange.NextStoryRange
myStoryRange.Fields.Update
Loop
Next myStoryRange
End Sub

A completely different approach is to make sure the "Update fields"
option in Tools Options Print is checked, and then switch the view
to Print Preview and back to Print Layout. As a macro, the code looks
like this:

Sub UpdateAllFields_2()
Dim oldOpt As Boolean

' save user's option, then set True
oldOpt = Options.UpdateFieldsAtPrint
Options.UpdateFieldsAtPrint = True

ActiveWindow.View = wdPrintPreview
ActiveWindow.View = wdPrintView

' restore user's option
Options.UpdateFieldsAtPrint = oldOpt
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org



I'm sorry it took a while to get back to you on this but thank you so much.
The print preview trick works just lovely.