View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Wayne Wayne is offline
external usenet poster
 
Posts: 133
Default Workbook_BeforePrint

Thanks Dave, it works a treat.
I was searching a pervious post and copied and tried the code but couldn't
make it work.

We have a person here who keeps claiming other peoples work as theirs, I
just wanted a simple way to print our names as "authors" in the footer when
they printed within excel.

Thanks again

Wayne

"Dave Peterson" wrote:

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