|
|
|
|
|
|
|
|
|
Word
|
Fill first page footer
|
|
|
Ease of Use
|
Easy
|
|
Version tested with
|
2000, 2002
|
|
Submitted by:
|
MOS MASTER
|
|
Description:
|
Fill the first page footer only with autotext entries. One will insert the filename and path (if the documents is saved or else only the temporary filename) and one will insert the last person who saved the document.
|
|
Discussion:
|
It's usually a good idea to insert the filename and path in your document to keep track of it. The same applies to the last person who saved a document. This sub only works if the section (1) has the folowing setting: Menu | File | Page setup | Layout | Different First Page. (to fill the first page footer)
|
|
Code:
|
instructions for use
|
Option Explicit
Sub PathInFooter()
Dim oRange As Word.Range
'Get a handle to the firstpage Footer
Set oRange = ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range
'Get autotext from Normal.dot
With NormalTemplate
'Insert Filename and path in footer
.AutoTextEntries("Filename and path").Insert Where:=oRange, RichText:=True
With oRange
'Insert paragraph mark after the filename
.InsertAfter Text:=vbCr
'Collapse to the end of the range
.Collapse Direction:=wdCollapseEnd
End With
'Insert Last saved by {Name} in footer
.AutoTextEntries("Last saved by").Insert Where:=oRange, RichText:=True
End With
'Clean up
Set oRange = Nothing
End Sub
|
|
How to use:
|
- Open your Word document.
- Press Alt + F11 to open VBE.
- Insert-Module. (Insert -> module)
- Paste the code there in the window at right. (F7)
- Close VBE (Alt + Q or press the X in the top right hand corner).
- Save the file.
|
|
Test the code:
|
- If you have your page setup for "Different first page" (File | Page setup | Layout | Different First Page) you can run the below sub to get that data in to the first page footer.
- Use Tools | Macro | Macro's and doubleclick: "PathInFooter"
|
|
Sample File:
|
Fill firstpage footer.zip 7.42KB
|
|
Approved by mdmackillop
|
|
This entry has been viewed 77 times.
|
|
|