Excel 2010 Before Print Event not working

Hi Experts,

I have some VBA code that I would like to run before the user sends the print job to the printer.  I have tried the BeforePrint event in the workbook tab VB and cannot get the code run.  I have even tried to simply the code as follows and still not working,

Private Sub Workbook_BeforePrint(Cancel As Boolean)

    MsgBox ("hi")

End Sub

Any thoughts on what could prevent this from running?

Thanks in advance

jj
JJINFMAsked:
Who is Participating?
 
Rory ArchibaldConnect With a Mentor Commented:
I think the lack of event from the backstage preview is by design, but actually printing or doing a full screen preview should fire it.
0
 
Rory ArchibaldCommented:
It appears to be a bug. I've seen reports that it doesn't work 'by design' when using the backstage preview but it was supposed to work using the old full screen print preview, however I cannot get it to fire ever in my tests. I will file it as a bug.
0
 
JJINFMAuthor Commented:
OK, how to I resolve this open question.  Do I accept your comment as a solution?
0
 
Rory ArchibaldCommented:
I'd suggest you leave it open for the time being and I will see if I get a response from MS that I can pass on, even if it's just confirmation of the issue.
0
 
Rory ArchibaldCommented:
Hmm, just retested and after compiling my code I can now get the event to fire for a full screen preview or a print, but not from a Backstage preview (i.e. the File-Print screen) unless I actually print.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.