Application level event handler broken in 2003SP1 ?

A

Alex T

Folks

I have a pretty standard class I use to trap application events

-----------------------------------------------------------------
Option Explicit
Public WithEvents myApp As Excel.Application

Private Sub myApp_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)

' - Traps the close event

' DO STUFF

End Sub
-----------------------------------------------------------------

Which I initialize using this code snippet

-----------------------------------------------------------------
Public gThisApp As clsApplication
Set gThisApp.myApp = Excel.Application
-----------------------------------------------------------------

Resulting in the following error

I'm pretty sure this was working just fine before applying 2003SP1...

Am I missing something obvious ? Any pointer ?

Thanks & regards

--AlexT
 
T

Tom Ogilvy

Try changing
Public gThisApp As clsApplication

to
Public gThisApp As New clsApplication
 
R

R Avery

I think you have to set gThisApp = New clsApplication first. I believe
that is the object it is referring to.
 
A

Alex T

Public gThisApp As New clsApplication

Yep, that was the trick.

Strange that it ever worked... Probably some kind of unwanted side effect.

Regards

--alexT
 
Top