Solved

FilePath in Word 2003 or 2007 footer auto-update

Posted on 2008-10-12
4
2,833 Views
Last Modified: 2011-10-19
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
Comment
Question by:npasic
  • 2
4 Comments
 
LVL 35

Expert Comment

by:torimar
ID: 22698664
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
 

Author Comment

by:npasic
ID: 22702269
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
 
LVL 35

Expert Comment

by:torimar
ID: 22704858
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
 
LVL 1

Accepted Solution

by:
benleicester earned 500 total points
ID: 23037173
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
word 2013 3 74
Only use the last record in an Excel sheet with a Word mail merge 5 46
Header of docx file 17 96
MS Word document > cursor placement 5 22
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now