View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Application Event Procedure <Falling Over

Hi Tim,

If I follow you are trapping application level events and want to cater for
the possibility the class holding the app ref has been destroyed, eg by user
pressing the reset button. You could set a boolean flag, which if false
would indicate your variables have been destroyed. However you might just as
well amend your routine -

Sub Reset_EnableEvents()
If AppClass is nothing then
set AppClass = new ClassName
Set AppClass.App = Application
end if

End Sub

I can't think of anything that will automatically tell you that your
AppClass no longer exists, so you would need to check periodically. In
theory you could trap the VBE Reset button-click event but there are other
ways your ref could be destroyed. Perhaps look into the OnTime method with
Schedule to run the amended Reset_EnableEvents routine (don't forget to
clear it when done).

Regards,
Peter T



"Tim Childs" wrote in message
...
Hi



I am using the software from (the peerless) Chip Pearson's site that helps
with Application Event programming.



The event I have is as follows:

Private Sub App_WorkbookOpen(ByVal Wb As Excel.Workbook)

Etc etc

End Sub



Some time ago someone on the ng helped me by supplying this code to deal
with the situation when the VB Project has <fallen over e.g. if a

Run-Reset
has happened etc or a runtime error has been finished by the user pressing
"End" on the dialog box.

Sub Reset_EnableEvents()

Set AppClass.App = Application

End Sub



Is there a property in VB that can identify if that reset has occurred

i.e.
can one determine programmatically if it is necessary to run the procedure
Reset_EnableEvents?



Thanks



Tim