Filename field does not update automatically
hello friends,
When I tried to open a document in Microsoft Word 2003 , the FILENAME field (and path if applicable) does not update to the name and the location of the file that I just opened. How can I update the filename field in Word ?
Can anyone help.....
Re: Filename field does not update automatically
To automatically update the field that is contained in your Word document, create an AutoOpen macro. To do this, follow these steps:
- Start Word and open the document that contains the field that will not update automatically.
- 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.
- In the Macros dialog box, follow these steps:
- In the Macro name box, type AutoOpen.
- Change the Macros in box to your document file name.
- Click Create.
- In the code sheet of the Microsoft Visual Basic editor, you should now see the beginnings of your AutoOpen macro. You should see the following:
Code:
Sub AutoOpen()
'
' AutoOpen Macro
' Macro created date by username
'
End Sub
- Type, or copy and paste, the following macro code into your AutoOpen macro:
Code:
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
- Your AutoOpen macro should now look like:
Code:
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
- On the File menu, click Save Filename.
- On the File menu, click Close and Return to Microsoft Word.
- 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.
- 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.
- Close your document.
- Reopen your Word document.
- Click Enable Macros in the Security Warning dialog box.
The field should now update automatically in your Word document.
Re: Filename field does not update automatically
You can also update the filename field manually - just select the field that is contained in your Word document, and then press F9.