I am using Excel automation in C++ (EXE) that is listening to Excel events.
Once the user opens the Excel app, I am able to reference the _Application pointer via the AccessibleObjectFromWindow function.
After this - I am able to connect to the IID_IConnectionPointContainer and get the various events.
My issue is the following: If my program crashes (or if I stop the debugger), I am not able to properly clean the _Application pointer, so Excel.EXE is still running even if the user has closed the program.
This makes sense since the _Application ref count is still 1.
However, if the user opens the Excel.EXE again -> It starts without any add-ins. The user needs to manually add the ribbons. This behaviour will continue until the Excel.EXE is manually killed.
Did anyone experience such an issue? Is there a way to clean COM object pointers after my app crashes?