|
|
|
|
|
|
Word
|
Footer with Path and File name, Date and Time
|
|
Ease of Use
|
Intermediate
|
Version tested with
|
|
Submitted by:
|
JOrzech
|
Description:
|
This macro will insert a footer into your document which contains the path and file name, as well as the current date and time. When the document is moved, the footer automatically updates.
|
Discussion:
|
This macro allows you to track the location of a document, whether it's stored on a hard drive or on a network. If the document is moved, the location will automatically update so you will always know where your document resides.
If you like this macro, consider learning how to record macros. This is a very simple macro that you could record yourself, and use over and over in many different documents.
|
Code:
|
instructions for use
|
Sub AddFooter()
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End If
Selection.Font.Size = 8
NormalTemplate.AutoTextEntries("Filename and path").Insert Where:= _
Selection.Range
Selection.TypeParagraph
Selection.InsertDateTime DateTimeFormat:="M/d/yyyy h:mm am/pm", _
InsertAsField:=True, DateLanguage:=wdEnglishUS, CalendarType:= _
wdCalendarWestern, InsertAsFullWidth:=False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
|
How to use:
|
- Hit Alt+F11 to open the Visual Basic Editor (VBE).
- Make sure Project Explorer is visible (View, Project Explorer)
- Double-click on Normal (or normal.dot) at the left of the window.
- Insert, Module and paste this code into the window at right.
- Hit the Save toolbar button and close the VBE.
- Hit Alt+F11 to return to Word.
- Exit Word. If you're asked to save normal.dot, say yes.
|
Test the code:
|
- Open a blank document.
- Hit Tools-Macro-Macros, and double-click AddFooter.
|
Sample File:
|
No Attachment
|
Approved by Anne Troy
|
This entry has been viewed 127 times.
|
|