After Print Event VBA

Posted on 2014-02-23
Medium Priority
Last Modified: 2016-09-15
Hello Gurus,

Is there a  after print event in VBA? For example I want to clear a range every time the users press the print button to print? But I need the range to clear-ONLY after the print job has ended and printing finished

Thank you
Question by:Rayne
LVL 28

Assisted Solution

MacroShadow earned 1000 total points
ID: 39881728
There is no AfterPrint event, but there is a workaround:

Copy this code to the Workbook module:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Application.OnTime Now, "AfterPrint"
End Sub

Open in new window

And this to a regular module:
Private Sub AfterPrint()
    'the code you want to run after the print event
End sub

Open in new window

LVL 54

Accepted Solution

Rgonzo1971 earned 1000 total points
ID: 39881729

pls try

Private Sub Workbook_BeforePrint(Cancel As Boolean) 
    Cancel = True
    Application.EnableEvents = False 
    Application.EnableEvents = True 
    MsgBox "Printing Done" 
End Sub 

Open in new window


Author Closing Comment

ID: 39881764
Thank you Guys :)

Expert Comment

by:anony Mous
ID: 41799336
I have tried the codes above.

MacroShadow's works well even if you print multiple sheets.

Rgonzo1971's is simple but can only print one sheets. if you select multiple sheets, it will only print the original sheet.

thanks guys. i also used this

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Currently, there is an issue with being able to copy values from an external application to a dropdown list in Project Web Access (PWA).  The standard copy and paste methods don't seem to work properly. Here is a way to accomplish this task to s…
Are you looking to start a business? Do you own and operate a small company? If so, here are some courses you need to take before you hire a full-time IT staff.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
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…

619 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