Solved

After Print Event VBA

Posted on 2014-02-23
4
2,975 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
[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
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 50

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
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 demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

749 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