Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook_BeforePrint
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How store PageBrakes locations - Coded pagebrakes are deleted in Workbook_BeforePrint | Excel Programming | |||
Workbook_BeforePrint performs twice ? | Excel Programming | |||
disable print option, not Workbook_BeforePrint | Excel Programming | |||
Workbook_BeforePrint | Excel Programming | |||
Problem - Workbook_BeforePrint | Excel Programming |