View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default How to register an event handler when excel opens

John,

you'll need to setup a classmodule to hook into
excel's application object.from there you can monitor all events
within the running instance of excel.

Here's how:

in your app:

insert a new classmodule
rename it to :clsAppEvent


'code for clsAppEvent
Option Explicit
Dim WithEvents xlApp As Application
Private Sub Class_Initialize()
Set xlApp = Application
End Sub
Private Sub xlApp_WorkbookOpen(ByVal Wb As Workbook)
MsgBox "you opened " & Wb.Name
End Sub


'code for ThisWorkbook
Option Explicit
Dim appMon As clsAppEvent
Private Sub Workbook_Open()
Set appMon = New clsAppEvent
End Sub

as long as there's no stateloss.. everytime a workbook is opened
you'll get a message.

Hopefully this is illustrative of the technique,
now you can search & find lots of other examples.




keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"John Davidson" wrote:

Folks,

I have written an event handler to to validate the work book name
before
saving a work book. Ineed to know what code do I have to write to
have the event handler register itself when Excel starts.

Also is there some install procedure where I can move my code and
user
from into the personal.xls in the XLSStart directory? I can do it by
hand but that is a pain.

Thanks,

{John}

I miss Cusp and Mesa.