I'm working on a very old piece of legacy code written in COM/ATL. It has a pointer to the excel application (_Application) and uses this pointer to run a VBA macro. The language is something along the lines of _Application->Run([macroname]);

During the macro, one of the lines of VBA code calls into another of my COM objects, and this object implements a wait loop. The wait loop can take anywhere from milliseconds to minutes. The hope was that if the wait is taking too long, the user could push the VBE toolbar button (blue square) that's referred to as either "VBA Stop" or "VBA Reset". Unfortunately, the environment can't process this toolbar button click until the call to the COM object has returned control back to VBA, which means allowing the full timeout to play out (again, possibly minutes). It then returns from the initial _Application->Run call with a "_com_Error" whose number indicates that the reset button has been pushed. This is not quite what I need.

Is there a way from the COM wait loop to use its _Application pointer to query if that button has been pushed, which would then allow me to break out of the loop early? I've tried making a second _Application->Run call back into an empty macro, which does immediately return with the _com_error, but this solution has other bad side effects. It does appears that the _Application object somewhere internally sets a flag saying that the Stop/Reset button was set, but I haven't been able to find a way to query it.