Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need to capture an event for AFTER printing in EXCEL

Posted on 2006-10-21
9
Medium Priority
?
490 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
[X]
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
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
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
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

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.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

722 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