The FILENAME field does not automatically update when you open a document in Word

Article translations Article translations
Article ID: 832897 - View products that this article applies to.
Expand all | Collapse all

On This Page

SYMPTOMS

When you open a document in one of the versions of Microsoft Word that is listed in the "Applies to" section of this article, the FILENAME field (and path if applicable) does not update to the name and the location of the file that you just opened.

CAUSE

This behavior is a design change in Microsoft Word 2002 and later to permit your Word document that contains a FILENAME field to open more quickly.

WORKAROUND

To work around this behavior, use one of the following methods.

Method 1: Update the field manually

To update the field manually, select the field that is contained in your Word document, and then press F9.

Method 2: Create a macro to automatically update the field

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To automatically update the field that is contained in your Word document, create an AutoOpen macro. To do this, follow these steps:
  1. Start Word and open the document that contains the field that will not update automatically.
  2. In Microsoft Office Word 2003 or in Word 2002, on the Tools menu, point to Macro, and then click Macros.

    In Microsoft Office Word 2007, click the Developer tab, and then click Macros in the Code group.
  3. In the Macros dialog box, follow these steps:
    1. In the Macro name box, type AutoOpen.
    2. Change the Macros in box to your document file name.
    3. Click Create.
  4. In the code sheet of the Microsoft Visual Basic editor, you should now see the beginnings of your AutoOpen macro. For example, you should see the following:
    Sub AutoOpen()
    '
    ' AutoOpen Macro
    ' Macro created date by username
    '
    
    End Sub
    
  5. Type, or copy and paste, the following macro code into your AutoOpen macro:
       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
    
  6. Your AutoOpen macro should now look similar to the following example:
    Sub AutoOpen()
    '
    ' AutoOpen Macro
    ' Macro created date by username
    '
    
       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
    
    End Sub
    
  7. On the File menu, click Save Filename.
  8. On the File menu, click Close and Return to Microsoft Word.
  9. In Word 2003 or Word 2002, on the Tools menu, point to Macro, and then click Security.

    In Word 2007, click the Developer tab, and then click Macro Security in the Code group.
  10. In Word 2003 or Word 2002, on the Security Level tab, change your security level to Medium, and then click OK.

    In Word 2007, under Macro Settings, click to select the Enable all macros option.
  11. Close your document.
  12. Reopen your Word document.
  13. Click Enable Macros in the Security Warning dialog box.
The field should now update automatically in your Word document.

MORE INFORMATION

The FILENAME field will be updated automatically when you switch to print preview or when you print the document.

For more information, click the following article number to view the article in the Microsoft Knowledge Base:
211629 Which fields are updated when you open, repaginate, or print document
For more information about AutoOpen macros, click the following article number to view the article in the Microsoft Knowledge Base:
286310 Behavior of AutoExec and AutoLoad macros in Word

Properties

Article ID: 832897 - Last Review: September 18, 2011 - Revision: 6.0
APPLIES TO
  • Microsoft Office Word 2007
  • Microsoft Word 2002
Keywords: 
kbprb KB832897

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com