Solved

FilePath in Word 2003 or 2007 footer auto-update

Posted on 2008-10-12
4
2,821 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

758 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

19 Experts available now in Live!

Get 1:1 Help Now