Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Mar 2005
    Location
    London, Hampshire, United Kingdom
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File stamp (Word 2007)

    Can anyone offer a macro to open a footer and print the path of the file (with the date would be even better) - probably obvious when you know how!

    Thanks.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: File stamp (Word 2007)

    If your document has a single section with just the standard footer, you can use this:
    <code>
    Sub AddFooter()
    Dim rng As Range
    With ActiveDocument.Sections(1).Footers(wdHeaderFooterP rimary)
    Set rng = .Range
    rng.Text = ""
    ActiveDocument.Fields.Add Range:=rng, Text:="FILENAME p"
    rng.InsertAfter vbTab & vbTab
    rng.Collapse Direction:=wdCollapseEnd
    ActiveDocument.Fields.Add Range:=rng, Text:="DATE @ ""d MMMM yyyy"""
    End With
    End Sub
    </code>
    You can change the date format d MMMM yyyy.

  3. #3
    Star Lounger
    Join Date
    Mar 2005
    Location
    London, Hampshire, United Kingdom
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File stamp (Word 2007)

    Thank you once again, Hans. What a memory you must have!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: File stamp (Word 2007)

    If your document has multiple sections and/or non-standard footers (such as first-page footers), you can use the following macro:
    <code>
    Sub AddFooter()
    Dim sec As Section
    Dim ftr As HeaderFooter
    Dim rng As Range
    For Each sec In ActiveDocument.Sections
    For Each ftr In sec.Footers
    If ftr.Exists Then
    If sec.Index = 1 Or ftr.LinkToPrevious = False Then
    Set rng = ftr.Range
    rng.Text = ""
    ActiveDocument.Fields.Add Range:=rng, _
    Text:=" FILENAME p", _
    PreserveFormatting:=False
    rng.InsertAfter vbTab & vbTab
    rng.Collapse Direction:=wdCollapseEnd
    ActiveDocument.Fields.Add Range:=rng, _
    Text:="DATE @ ""d MMMM yyyy", _
    PreserveFormatting:=False
    End If
    End If
    Next ftr
    Next sec
    End Sub
    </code>
    This will apply the same text to all footers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •