Solved

FilePath in Word 2003 or 2007 footer auto-update

Posted on 2008-10-12
4
2,866 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
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 …

635 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