PDA

View Full Version : Update worksheet footer on save Excel 2003



Grappa
01-22-2008, 02:43 AM
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

Bob Phillips
01-22-2008, 03:28 AM
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


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

Grappa
01-25-2008, 02:30 AM
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