Consulting

Results 1 to 3 of 3

Thread: Update worksheet footer on save Excel 2003

  1. #1
    VBAX Newbie
    Joined
    Jan 2008
    Posts
    2
    Location

    Update worksheet footer on save Excel 2003

    Hi,

    Really appreciate if someone could advise the best mechanism to update a footer on saving a workbook.

    I have following code that updates the footer:

    Private Sub UpdateFooter()
    Dim Ws As Worksheet
    For Each Ws In Worksheets
    Ws.PageSetup.LeftFooter = "Test"
    Next Ws
    End Sub

    I don't seem to be able to find a mechanism to call this when the user saves the file.

    Any help appreciated.

    Simon

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim Ws As Worksheet
    For Each Ws In Worksheets
    Ws.PageSetup.LeftFooter = "Test"
    Next Ws
    End Sub
    [/vba]

    This is workbook event code.
    To input this code, right click on the Excel icon on the worksheet
    (or next to the File menu if you maximise your workbooks),
    select View Code from the menu, and paste the code
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Newbie
    Joined
    Jan 2008
    Posts
    2
    Location
    Thanks very much for your help.I'd actually got the code right eventually but was creating it in a separate module rather than the workbook and hence it wasn't running before the save event.

    Regards,

    Simon

Posting Permissions

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