Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How store PageBrakes locations - Coded pagebrakes are deleted in Workbook_BeforePrint Marie J-son[_6_] Excel Programming 1 May 8th 05 02:49 PM
Workbook_BeforePrint performs twice ? Peter[_21_] Excel Programming 3 November 29th 04 01:24 AM
disable print option, not Workbook_BeforePrint Andoni[_4_] Excel Programming 0 July 27th 04 11:40 PM
Workbook_BeforePrint Squid[_2_] Excel Programming 2 May 11th 04 04:18 PM
Problem - Workbook_BeforePrint JON-JON Excel Programming 3 August 26th 03 01:19 PM


All times are GMT +1. The time now is 04:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"