personal.xls

B

Brian2577

Question about personal.xls workbook.

Entering the code below in the personal.xls workbook will activate th
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 i
will not automatically activate the msgbox before print and befor
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 befor
printing and closing for all workbooks?

Thanks,
Bria
 
D

Darren Hill

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

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

Chip Pearson

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"
message
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top