Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

After Print Event VBA

Posted on 2014-02-23
4
Medium Priority
?
3,591 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 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

1
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 1000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

722 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