BeforePrint event handler activeworkbook

dohc46

New Member
Joined
Mar 14, 2013
Messages
7
Hello,
I don't understand why it appears that event handlers are only good for one workbook, meaning...

At work the printer adm group defaults the printer to print double side and in black and white. I want a message box to pop up regardless of what workbook I want to print reminding me to change settings if I want to.

This code works fine ONLY IF I am printing from this workbook in which the code is in. How can I get this code to work, regardless of what workbook I want to print? Thank you. (this concept/answer - probably useful for other event handlers I would guess).

VBA Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim msgresponse

    msgresponse = MsgBox("Did you remember to change printer default settings: color & double sided?", vbYesNo)
   
    If msgresponse = vbNo Then Cancel = True

End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You could sink the workbooks events at the application level. If you place that in an addin, the event sinking remains functional throughout the use of the excel application.

Do a search for "Application Events" , "WithEvents" keywords.
 
Upvote 0

Forum statistics

Threads
1,213,532
Messages
6,114,177
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