Jaafar Tribak
Well-known Member
- Joined
- Dec 5, 2002
- Messages
- 9,856
- Office Version
- 2016
- Platform
- Windows
Hi all.
Here is the deal - Suppose the application is hooked upon opening the workbook like so :
This should keep the application hooked as long as the AppEvents Variable points to the application object. However if the Project is reset by the user or simply some code accidently errors out , this will inforce the reinitialization of all variables including the AppEvents variable and obviously the application will cease to be hooked.
Any ideas on how to work around this and make the application's events persistent throughout ?
Regards.
Here is the deal - Suppose the application is hooked upon opening the workbook like so :
Code:
Private WithEvents AppEvents As Application
Private Sub Workbook_Open()
Set AppEvents = Application
End Sub
Private Sub AppEvents_NewWorkbook(ByVal Wb As Workbook)
MsgBox "hello!"
End Sub
This should keep the application hooked as long as the AppEvents Variable points to the application object. However if the Project is reset by the user or simply some code accidently errors out , this will inforce the reinitialization of all variables including the AppEvents variable and obviously the application will cease to be hooked.
Any ideas on how to work around this and make the application's events persistent throughout ?
Regards.