Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 7 of 7

Thread: Workbook_BeforePrint(Cancel As Boolean) ...how about AfterPr

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    Houston TX
    Posts
    550
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Would like to capture a AFTERPRINT event in EXCEL 97.

    Thank you.

  2. #2
    MrExcel MVP Damon Ostrander's Avatar
    Join Date
    Feb 2002
    Location
    Denver, Colorado USA
    Posts
    4,239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Bill,

    There is no AfterPrint event, but you can effectively create your own using the BeforePrint event as follows:

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Static PrintRequest As Boolean

    If PrintRequest = True Then Exit Sub

    PrintRequest = True
    ActiveSheet.PrintOut

    'PUT YOUR AfterPrint CODE HERE
    'This code will execute AFTER the print is completed

    PrintRequest = False
    Cancel = True
    End Sub

    The way this works is simply to cancel the manually-requested print, and instead execute a print from VBA so that right after the print you can do whatever operation you want.

    Keep Excelling.

    Damon
    Keep Excelling.

    Damon

    VBAexpert Excel Consulting
    LinkedIn Profile http://www.linkedin.com/pub/damon-ostrander/7/79/a93
    AllExperts Profile http://www.allexperts.com/ep/1059-30...-Ostrander.htm

  3. #3
    MrExcel MVP Barrie Davidson's Avatar
    Join Date
    Feb 2002
    Location
    Winnipeg
    Posts
    2,330
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Damon, what a great idea! I've encountered this before and never even thought of going that route.

    Regards,
    Barrie Davidson

    "You're only given a little spark of madness. You mustn't lose it." - Robin Williams

  4. #4
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Damon

    Good idea.....however it's the Printpreview
    that usually is the problem for Print event
    codes....ie. code will also run in Printpreview........I'm trying to work on
    code around this...so far I only have a hack


    cheers

    Ivan

  5. #5
    Board Regular
    Join Date
    Mar 2002
    Location
    Houston TX
    Posts
    550
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Damon,

    That was an excellent Idea.

    Not too sure about IVAN and the problem he faces using PRINT PREVIEW...

    4 now though, the solution is what the doctor ordered!
    Bill



  6. #6
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-11 06:43, bill wrote:
    Damon,

    That was an excellent Idea.

    Not too sure about IVAN and the problem he faces using PRINT PREVIEW...

    4 now though, the solution is what the doctor ordered!
    Bill


    Hi Bill...the problem is when you do a printpreview the "AFTER print event" will
    still run...try it and see....
    This is what I'm trying to work over...
    at the moment I just have a Hack fix...

    Ivan

  7. #7
    Board Regular
    Join Date
    Mar 2002
    Location
    Houston TX
    Posts
    550
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks Ivan,

    I actually noticed the flaw when an associate dropped a stack of printouts on my desk due to print preview

    No fix yet I presume?

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •