Solved

Need to capture an event for AFTER printing in EXCEL

Posted on 2006-10-21
9
472 Views
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.
0
Comment
Question by:spoowiz
  • 2
  • 2
  • 2
  • +1
9 Comments
 
LVL 142

Accepted Solution

by:
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:
http://www.dailydoseofexcel.com/archives/category/vba/events/
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...
0
 
LVL 9

Assisted Solution

by:gopal_krishna
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.)

Regards
Gopal Krishna K
0
 

Author Comment

by:spoowiz
ID: 17782826
The reason I wanted "after" is I wanted to make sure the user actually printed, instead of cancelling the print.
0
 
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)?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

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

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:
http://vbcity.com/forums/faq.asp?fid=9&cat=General
0
 
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... :) ]

BFN,

fp.
0
 
LVL 9

Expert Comment

by:gopal_krishna
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.

Cheers
Gopal krishna K
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In case Office 2010 has not been deployed in your environment, this article may be quite useful. In our office, we wanted a way to deploy Microsoft Office Professional Plus 2010 through an automated batch file via logon script. This article is docum…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now