Need to capture an event for AFTER printing in EXCEL

Posted on 2006-10-21
Last Modified: 2012-08-13
I need to capture an event for AFTER printing in Excel.
Workbook_BeforePrint doesn't do it because it's BEFORE and it also gets trapped when user PREVIEWS print.

Can someone help with this? Thanks.
Question by:spoowiz
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 100 total points
ID: 17780717
I could imagine that capturing the print button click event might get a step further.
here is a page where I found the steps to capture the events of a button or command bar:
in the sample it's the delete button, but the principle is the same (you have to locate the button).

however, I guess that the print button clicked does not mean the print OK button clicked in the dialog...
not sure how one could capture that...

Assisted Solution

gopal_krishna earned 75 total points
ID: 17782777
There is a workbook_beforeprint that you can tie into.

But there is no workbook_afterprint event.

maybe you could work off a timer???

Behind the ThisWorkbook module:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)

'your beforeprint code here

Application.OnTime Now + TimeSerial(0, 0, 10), "RunAfterPrint"

End Sub

Then in a general module:

Option Explicit
Sub runAfterPrint()
'your code here
End Sub

(I waited 10 seconds. Adjust as necessary.)

Gopal Krishna K

Author Comment

ID: 17782826
The reason I wanted "after" is I wanted to make sure the user actually printed, instead of cancelling the print.
RoboForm Secure Password Management System

RoboForm Everywhere - Superb Browser Support
Windows / Apple / IOS / Android / Linux / Chrome OS
Use different complex passwords everywhere
Best Secure Password Management by far
Synchronize all of your devices instantly
Safe, Secure & Highly Recommended!

LVL 35

Expert Comment

by:[ fanpages ]
ID: 17800939
"The reason I wanted "after" is I wanted to make sure the user actually printed, instead of cancelling the print."

What if the user elected to "print" but the printer failed (due to a paper jam, or lack of ink, or connectivity)?

Author Comment

ID: 17800976
you've got a point. that's a loophole i'm willing to live with.
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17801099
Well, the only "solution" I see is that you scan the printer queue to see if the job arrives there and it the job seems to complete...
will be a polling method:
LVL 35

Assisted Solution

by:[ fanpages ]
[ fanpages ] earned 75 total points
ID: 17801215
...the code based on the suggestion made by angelIII would need to determine if a specific spooled job had 'completed' successfully, or whether the absence of an allocated JobId in the queue was because of remote or local cancelling of the print job.

Also, the spool queue for a print driver that allows the retaining of jobs in the queue after printing would also require some though.

[So many issues makes you wonder why Microsoft didn't offer an "AfterPrint" event... :) ]



Expert Comment

ID: 18066009
beforeprint is the only option which comes. there is no other options as after print. fanpages as said that was app correct there are many reason that microsoft has not provided this option.

Gopal krishna K

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question