+ Reply to Thread
Results 1 to 3 of 3

personal.xls

  1. #1
    Registered User
    Join Date
    12-16-2005
    Posts
    4

    personal.xls

    Question about personal.xls workbook.

    Entering the code below in the personal.xls workbook will activate the message box every time I open any Excel application.

    Public Sub Workbook_Open()
    MsgBox ("Hello")
    End Sub

    However, when I enter the following code in the personal workbook it will not automatically activate the msgbox before print and before close.

    Sub Workbook_Activate()
    MsgBox ("Print")
    End Sub

    Public Sub Workbook_BeforeClose(Cancel As Boolean)
    MsgBox ("goodbye")
    End Sub

    Why is this and how can I program a certain event to happen before printing and closing for all workbooks?

    Thanks,
    Brian

  2. #2
    Darren Hill
    Guest

    Re: personal.xls

    There's a BeforePrint event which sounds like what you need

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    MsgBox ("Print")
    End Sub


    On Sat, 17 Dec 2005 01:35:29 -0000, Brian2577
    <[email protected]> wrote:

    >
    > Question about personal.xls workbook.
    >
    > Entering the code below in the personal.xls workbook will activate the
    > message box every time I open any Excel application.
    >
    > Public Sub Workbook_Open()
    > MsgBox ("Hello")
    > End Sub
    >
    > However, when I enter the following code in the personal workbook it
    > will not automatically activate the msgbox before print and before
    > close.
    >
    > Sub Workbook_Activate()
    > MsgBox ("Print")
    > End Sub
    >
    > Public Sub Workbook_BeforeClose(Cancel As Boolean)
    > MsgBox ("goodbye")
    > End Sub
    >
    > Why is this and how can I program a certain event to happen before
    > printing and closing for all workbooks?
    >
    > Thanks,
    > Brian
    >
    >




    --
    ------------------
    Darren

  3. #3
    Chip Pearson
    Guest

    Re: personal.xls

    The events in the personal.xls workbook, as you have them
    written, apply only to that workbook. For example, the Activate
    event will trigger only when personal.xls workbook is activated,
    not when any workbook is activated. You probably need to use
    application events. See
    http://www.cpearson.com/excel/appevent.htm for details.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Brian2577"
    <[email protected]> wrote in
    message
    news:[email protected]...
    >
    > Question about personal.xls workbook.
    >
    > Entering the code below in the personal.xls workbook will
    > activate the
    > message box every time I open any Excel application.
    >
    > Public Sub Workbook_Open()
    > MsgBox ("Hello")
    > End Sub
    >
    > However, when I enter the following code in the personal
    > workbook it
    > will not automatically activate the msgbox before print and
    > before
    > close.
    >
    > Sub Workbook_Activate()
    > MsgBox ("Print")
    > End Sub
    >
    > Public Sub Workbook_BeforeClose(Cancel As Boolean)
    > MsgBox ("goodbye")
    > End Sub
    >
    > Why is this and how can I program a certain event to happen
    > before
    > printing and closing for all workbooks?
    >
    > Thanks,
    > Brian
    >
    >
    > --
    > Brian2577
    > ------------------------------------------------------------------------
    > Brian2577's Profile:
    > http://www.excelforum.com/member.php...o&userid=29713
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=494279
    >




+ 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