Results 1 to 12 of 12
  1. #1
    2 Star Lounger
    Join Date
    May 2006
    Location
    Portland, Oregon, USA
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Last page footer (2003)

    I've written a procedure using VBA that inserts a Certificate of Service at the end of a pleading. Now I want to change the footer to read "Certificate of Service" instead of the pleading title. I'm stuck in how to use VBA to find the last page footer. I found an example that finds the first page header, but changing the obvious produces an error. Any ideas?
    Charlotte
    Charlotte Quiroz

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Last page footer (2003)

    Hi Hans,

    That'd be:
    { IF {PAGE} = {NUMPAGES} "Certificate of Service" "Other text" }
    for the field <img src=/S/wink.gif border=0 alt=wink width=15 height=15>
    Cheers,

    Paul Edstein
    [MS MVP - Word]

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

    Re: Last page footer (2003)

    Thanks, I had Access on my mind when I wrote this (the number of pages in an Access report is Pages). I will correct my previous reply.

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

    Re: Last page footer (2003)

    Edited by HansV to correct error - thanks to Macropos for pointing it out

    The last page doesn't have a footer of its own. One option is to insert a section break before the last page, and use code like this:

    With ActiveDocument.Sections(ActiveDocument.Sections.Co unt).Footers(wdHeaderFooterPrimary)
    .LinkToPrevious = False
    .Range.Text = vbTab & "Certificate of Service"
    End With

    Another option is to use an IF field in the footer:

    { IF {PAGE} = {NUMPAGES} "Certificate of Service" "Other text" }

  5. #5
    2 Star Lounger
    Join Date
    May 2006
    Location
    Portland, Oregon, USA
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Last page footer (2003)

    I think you're on the right track. Maybe it will help to see what I have:
    First I add a section break, then I want to open the header footer and go to the last page footer.
    Here is that portion...

    'Open Header/Footer
    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

    If Selection.HeaderFooter.IsHeader = True Then
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    Selection.HeaderFooter.LinkToPrevious = False
    Else
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    End If

    Selection.WholeStory
    With Selection
    .TypeText "CERTIFICATE OF SERVICE"
    With Selection.Font
    .AllCaps = True
    .Bold = True
    End With
    End With

    Thanks...crq
    Charlotte Quiroz

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

    Re: Last page footer (2003)

    It isn't necessary to enter header/footer view in order to set the footer text - the code in my previous reply shows how to set the text without switching the view.

  7. #7
    2 Star Lounger
    Join Date
    May 2006
    Location
    Portland, Oregon, USA
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Last page footer (2003)

    VERY COOL! It worked like a charm! How do you know all this stuff?
    Thank you very much
    Charlotte
    Charlotte Quiroz

  8. #8
    2 Star Lounger
    Join Date
    May 2006
    Location
    Portland, Oregon, USA
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Last page footer (2003)

    One more piece. Now instead of "type text" I want to insert an autotext entry into the footer (it has everything formatted just the way we want it).
    Charlotte Quiroz

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

    Re: Last page footer (2003)

    You can use code like this:
    <code>
    With ActiveDocument.Sections(ActiveDocument.Sections.Co unt).Footers(wdHeaderFooterPrimary)
    .LinkToPrevious = False
    Templates("Normal.dot").AutoTextEntries(MyEntry"). Insert Where:=.Range, RichText:=True
    End With
    </code>
    If the AutoText entry is stored in another template than Normal.dot, substitute the correct name, or replace Template("Normal.dot") with ActiveDocument.AttachedTemplate.
    Replace MyEntry with the name of the AutoText entry you want to insert.

  10. #10
    2 Star Lounger
    Join Date
    May 2006
    Location
    Portland, Oregon, USA
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Last page footer (2003)

    ActiveDocument.AttachedTemplate.AutoTextEntries("C ertOServiceFooter").Insert Where:=Selection.Range, RichText:=True
    This is what I had and it doesn't put the auto text entry in the footer, it appears at the end of the document. (but not in the footer)
    Charlotte Quiroz

  11. #11
    2 Star Lounger
    Join Date
    May 2006
    Location
    Portland, Oregon, USA
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Last page footer (2003)

    OK, I got it

    With ActiveDocument.Sections(ActiveDocument.Sections.Co unt).Footers(wdHeaderFooterPrimary)
    .LinkToPrevious = False
    .Range.Text = ""
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    ActiveDocument.AttachedTemplate.AutoTextEntries("C ertOServiceFooter").Insert Where:=Selection.Range, RichText:=True
    End With

    It works like a charm. Thanks for all your help.
    Charlotte
    Charlotte Quiroz

  12. #12
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Last page footer (2003)

    Your problem was the use of
    <code>Where:=Selection.Range</code>
    The code that Hans suggested used
    <code>Where:=.Range</code>
    which is equivalent to
    <code>Where:=ActiveDocument.Sections(ActiveDocumen t.Sections.Count).Footers(wdHeaderFooterPrimary).R ange</code>
    because of the <code>With</code> higher up in his code.

    StuartR

Posting Permissions

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