View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Workbook_BeforePrint

I put your code into the ThisWorkbook module and your code worked ok for me. It
put that "produced by MyName" in the footer.

If you want to actually print it, though, you'll want to change:
cancel = true
to
cancel = false

If you have some variable named myName, then you'd want:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = false
Worksheets("Sheet1").PageSetup.RightFooter = "Produced by " & myname
End Sub

I don't see why you're using the .enableevents stuff, though. If you were
printing something in your code, then it would make more sense--but you're just
letting excel do the printing.

Wayne wrote:

I'm trying to produce a footer before the printing.
I've tried putting this into a module and also into the sheet1 code area.

Any ideas wy it will not work?

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.EnableEvents = False
Cancel = True
Worksheets("Sheet1").PageSetup.RightFooter = "Produced by MyName"
Application.EnableEvents = True

End Sub


--

Dave Peterson