Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need to capture an event for AFTER printing in EXCEL

Posted on 2006-10-21
9
Medium Priority
?
494 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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 400 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 300 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 

Author Comment

by:spoowiz
ID: 17800976
you've got a point. that's a loophole i'm willing to live with.
0
 
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:
http://vbcity.com/forums/faq.asp?fid=9&cat=General
0
 
LVL 35

Assisted Solution

by:[ fanpages ]
[ fanpages ] earned 300 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Microsoft has changed the look and feel of Azure AD and Microsoft account sign-in pages so that you will have a more unified look and feel when moving between the two interfaces.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
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…

972 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