Solved

After Print Event VBA

Posted on 2014-02-23
4
2,475 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 26

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 48

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
My experience with Windows 10 over a one year period and suggestions for smooth operation
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

759 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

23 Experts available now in Live!

Get 1:1 Help Now