Excel as a Com Server is not released if the application is closed incorrectly

I am using Excel Automation in C ++ (EXE) that listens for Excel events. When the user opens the Excel application, I can refer to the _Application pointer using a function AccessibleObjectFromWindow

. After that - I can connect to IID_IConnectionPointContainer

and receive various events.

My problem is this: if my program crashes (or if I stop the debugger), I cannot clear the pointer correctly _Application

, so Excel.EXE still works even if the user has closed the program.This makes sense since the count _Application

is 1.

However, if the user reopens Excel.EXE -> It starts without any add-ons. The user needs to manually add ribbons. This behavior will continue until Excel.EXE is manually killed.

Has anyone experienced this problem? Is there a way to clear pointers to COM objects after an application crash?

+3


source to share





All Articles