Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2875
  • Last Modified:

FilePath in Word 2003 or 2007 footer auto-update

How can I modify FilePath field in Microsoft Word document to update itself automaticaly if document changed it's location on the computer?
Please see attached file that has FilePath already inserted on the footer.
tde-letterhead.doc
0
npasic
Asked:
npasic
  • 2
1 Solution
 
torimarCommented:
Try this:

View > Header and Footer; place the cursor in the footer, then select Insert > Field; in Field Names select "FileName", then select the formatting you like and in Field Options put a check mark in "Add path to filename".
0
 
npasicAuthor Commented:
that is exactly what I did but it does not update that path automaticaly if the file is moved to another folder and than opened
0
 
torimarCommented:
True. Sorry for not having tested my suggestion before posting.

Since the footer is not selected when you Select All in a document, even a manual update via F9 will only work when you place the cursor right on the field. But you wanted an automativ update anyways. As far as I can see, this will require a VBA macro.

Fortunately, someone has already written the code for this. You'll find it here: http://www.vbaexpress.com/kb/getarticle.php?kb_id=459
together with very detailed instructions on how to proceed.

You will only need the Sub "UpdateFooter ()" or, alternatively, "UpdateFooter2()".

When everything works fine, you may consider adding the code to the AutoExec macro, so that it will perform automaticall on opening the document.
0
 
benleicesterCommented:
Hi,

I think I have a relatively simple solution to this - if you follow the process described below, the footer will update automatically when you use File and Save As. Hope this helps...

Open normal.dotm and insert filename
On Developer tab in ribbon, click on Macros
Type FileSaveAs and then click Create
Delete the code already there and replace with:

Sub FileSaveAs()
Dim pRange As Word.Range
Dim oFld As Field
On Error GoTo Handler
Retry:
With Dialogs(wdDialogFileSaveAs)
    If .Show = 0 Then Exit Sub
End With
System.Cursor = wdCursorNormal
ActiveWindow.Caption = ActiveDocument.FullName
For Each pRange In ActiveDocument.StoryRanges
    Do
        For Each oFld In pRange.Fields
            If oFld.Type = wdFieldFileName Then
                oFld.Update
            End If
        Next oFld
        Set pRange = pRange.NextStoryRange
    Loop Until pRange Is Nothing
Next
ActiveDocument.Save
Exit Sub
Handler:
If Err.Number = 5155 Or Err.Number = 5153 Then
MsgBox Err.Decription, vbOKOnly
Resume Retry
End If
 ActiveDocument.Save
End Sub

Click on File and Save Normal

Click on File and Close and return to Microsoft Word

Save and Close

Open Word again and save document 1 as whatever. File should save, filename should automatically update and then file should re-save.

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now