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:

  1. Open your Word document.
  2. Press Alt + F11 to open VBE.
  3. Insert-Module. (Insert -> module)
  4. Paste the code there in the window at right. (F7)
  5. Close VBE (Alt + Q or press the X in the top right hand corner).
  6. Save the file.
 

Test the code:

  1. 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.
  2. Use Tools | Macro | Macro's and doubleclick: "PathInFooter"
 

Sample File:

Fill firstpage footer.zip 7.42KB 

Approved by mdmackillop


This entry has been viewed 96 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express