+ Reply to Thread
Results 1 to 5 of 5

ThisWorkbook BeforePrint

  1. #1
    Simon Shaw
    Guest

    ThisWorkbook BeforePrint

    Hi,

    I need to run code after a print job.
    I am using
    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    in ThisWorkbook to execute code prior to printing,
    but then I want to run code after printing.

    Thanks
    Simon

  2. #2
    STEVE BELL
    Guest

    Re: ThisWorkbook BeforePrint

    You might look into canceling the print at the beginning of the event.
    Than have the code initiate the print (in the code).
    Than continue your code to what you want to happen after the print.

    --
    steveB

    Remove "AYN" from email to respond
    "Simon Shaw" <simonATsimonstoolsDOTcom> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I need to run code after a print job.
    > I am using
    > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    > in ThisWorkbook to execute code prior to printing,
    > but then I want to run code after printing.
    >
    > Thanks
    > Simon




  3. #3
    JE McGimpsey
    Guest

    Re: ThisWorkbook BeforePrint

    Make sure that if you do this, you disable events prior to printing and
    reenable them afterward, or you'll loop until you run out of stack
    space. For instance:

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Cancel = True
    Application.EnableEvents = False
    ActiveSheet.PrintOut
    Application.EnableEvents = True
    'Your code here
    End Sub



    In article <[email protected]>,
    "Simon Shaw" <simonATsimonstoolsDOTcom> wrote:

    > Hi,
    >
    > I need to run code after a print job.
    > I am using
    > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    > in ThisWorkbook to execute code prior to printing,
    > but then I want to run code after printing.
    >
    > Thanks
    > Simon


  4. #4
    Simon Shaw
    Guest

    Re: ThisWorkbook BeforePrint

    what if the user was performing a print preview... how do I tell the
    difference?

    "JE McGimpsey" wrote:

    > Make sure that if you do this, you disable events prior to printing and
    > reenable them afterward, or you'll loop until you run out of stack
    > space. For instance:
    >
    > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    > Cancel = True
    > Application.EnableEvents = False
    > ActiveSheet.PrintOut
    > Application.EnableEvents = True
    > 'Your code here
    > End Sub
    >
    >
    >
    > In article <[email protected]>,
    > "Simon Shaw" <simonATsimonstoolsDOTcom> wrote:
    >
    > > Hi,
    > >
    > > I need to run code after a print job.
    > > I am using
    > > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    > > in ThisWorkbook to execute code prior to printing,
    > > but then I want to run code after printing.
    > >
    > > Thanks
    > > Simon

    >


  5. #5
    JE McGimpsey
    Guest

    Re: ThisWorkbook BeforePrint

    AFAIK, there's no way to detect the difference between Print and Print
    Preview.

    However, you can trap the Print Preview command with something like:

    CommandBars(1).Controls("File").Controls("Print Preview").OnAction:= _
    "MyMacro"

    and

    Commandbars("Standard").FindControl(id:=109).OnAction = "MyMacro"

    In article <[email protected]>,
    "Simon Shaw" <simonATsimonstoolsDOTcom> wrote:

    > what if the user was performing a print preview... how do I tell the
    > difference?


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1