![]() |
Application level event handler broken in 2003SP1 ?
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 Object variable or With block variable not set <<< I'm pretty sure this was working just fine before applying 2003SP1... Am I missing something obvious ? Any pointer ? Thanks & regards --AlexT |
Application level event handler broken in 2003SP1 ?
Try changing
Public gThisApp As clsApplication to Public gThisApp As New clsApplication -- Regards, Tom Ogilvy "Alex T" wrote in message om... 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 Object variable or With block variable not set <<< I'm pretty sure this was working just fine before applying 2003SP1... Am I missing something obvious ? Any pointer ? Thanks & regards --AlexT |
Application level event handler broken in 2003SP1 ?
I think you have to set gThisApp = New clsApplication first. I believe
that is the object it is referring to. Alex T wrote: 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 Object variable or With block variable not set <<< I'm pretty sure this was working just fine before applying 2003SP1... Am I missing something obvious ? Any pointer ? Thanks & regards --AlexT |
Application level event handler broken in 2003SP1 ?
Public gThisApp As New clsApplication
Yep, that was the trick. Strange that it ever worked... Probably some kind of unwanted side effect. Regards --alexT |
All times are GMT +1. The time now is 04:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com