Solved

Need to capture an event for AFTER printing in EXCEL

Posted on 2006-10-21
9
477 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 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Perhaps more familiar to developers who primarily use VBScript than to developers who tend to work only with Microsoft Office and Visual Basic for Applications (VBA), the Dictionary is a powerful and versatile class, and is useful …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

820 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