Workbook_BeforePrint(Cancel As Boolean) ...how about AfterPr

bill

Well-known Member
Joined
Mar 7, 2002
Messages
550
Would like to capture a AFTERPRINT event in EXCEL 97.

Thank you.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi Bill,

There is no AfterPrint event, but you can effectively create your own using the BeforePrint event as follows:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Static PrintRequest As Boolean

If PrintRequest = True Then Exit Sub

PrintRequest = True
ActiveSheet.PrintOut

'PUT YOUR AfterPrint CODE HERE
'This code will execute AFTER the print is completed

PrintRequest = False
Cancel = True
End Sub

The way this works is simply to cancel the manually-requested print, and instead execute a print from VBA so that right after the print you can do whatever operation you want.

Keep Excelling.

Damon
 
Upvote 0
Damon

Good idea.....however it's the Printpreview
that usually is the problem for Print event
codes....ie. code will also run in Printpreview........I'm trying to work on
code around this...so far I only have a hack


cheers

Ivan
 
Upvote 0
Damon,

That was an excellent Idea.

Not too sure about IVAN and the problem he faces using PRINT PREVIEW...

4 now though, the solution is what the doctor ordered!
Bill
 
Upvote 0
On 2002-03-11 06:43, bill wrote:
Damon,

That was an excellent Idea.

Not too sure about IVAN and the problem he faces using PRINT PREVIEW...

4 now though, the solution is what the doctor ordered!
Bill

Hi Bill...the problem is when you do a printpreview the "AFTER print event" will
still run...try it and see....
This is what I'm trying to work over...
at the moment I just have a Hack fix...

Ivan
 
Upvote 0
Thanks Ivan,

I actually noticed the flaw when an associate dropped a stack of printouts on my desk due to print preview:)

No fix yet I presume?
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,172
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top