Solved

After Print Event VBA

Posted on 2014-02-23
4
2,603 Views
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
0
Comment
Question by:Rayne
4 Comments
 
LVL 27

Assisted Solution

by:MacroShadow
MacroShadow earned 250 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

1
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 250 total points
ID: 39881729
HI,

pls try

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

Open in new window

Regards
0
 

Author Closing Comment

by:Rayne
ID: 39881764
Thank you Guys :)
0
 

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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
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 …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

920 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

14 Experts available now in Live!

Get 1:1 Help Now