How to automatically reconnect application events after a crash ?

Dave2

New Member
Joined
Apr 2, 2017
Messages
2
Application events are fired through the existence of a single object of type
"ClassApplicationEvents", for lack of a better class name.

This object variable dies when the application crashes.

I'm looking for a robust way to automatically recreate this object variable after a crash, hopefully without making the user invoke a macro.

Any ideas?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Generally, you would create your own class and include an object using WithEvents keyword. E.g.

Code:
Dim WithEvents xlApp As Excel.Application

To test whether it has crashed, do a test

Code:
If xlApp Is Nothing Then
' ....

would that work?

As far as "robust", you would probably need to be recording any data or parameters along the way, which can get complicated.
 
Upvote 0
The problem with your proposed solution is that user interaction with the application which you desire to "listen to" via application events may already be going on before the test and possible resurrection of the object variable you describe has been carried out.
 
Upvote 0
When a vbproject crash happens all variables are released including the variable holding the 'ClassApplicationEvents' class instance .

One way you could try is to reset the variable in a windows timer periodically say every second ... Not an elegant solution but should accomplish what you want.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,497
Messages
6,160,151
Members
451,625
Latest member
sukhman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top