What type of event use to automatically add footer?

  • Thread starter Thread starter Chet Shannon
  • Start date Start date
C

Chet Shannon

I am trying to automatically run some VBA code that will
place the "path of the current open worksheet", the "file
name" and the "current file date/time stamp" on the
footer of the file I have active.

My question is how should I have this "activate"? What I
mean is on what "event" should I have my code run? I
know how to create code that will run on "open
event" , "sheet activate" , "sheet change" and so on but
which event would you recommend that I use to trigger the
code to do this?

Thanks,
Chet
 
Hi Chet
I'd use the workbook_beforeprint event. E.g. something like the
following:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wkSht As Worksheet
For Each wkSht In Me.Worksheets
With wkSht.PageSetup
.CenterFooter = Me.FullName
End With
Next wkSht
End Sub
 
Thanks Frank! I will try that... Chet
-----Original Message-----
Hi Chet
I'd use the workbook_beforeprint event. E.g. something like the
following:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wkSht As Worksheet
For Each wkSht In Me.Worksheets
With wkSht.PageSetup
.CenterFooter = Me.FullName
End With
Next wkSht
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany




.
 
Is there a way that I can make this code execute on ANY
spreadsheet that I open? What I mean is I don't
necessarily want to embed this code into one
spreadsheet. I would like the code to automatically
execute for any spreadsheet that I have open.

Thanks,
Chet
 
Chet
See the thred above "How make code execute for ANY active workbook?"

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top