I have an excel program that is 'listening' for events on an external object.
It's defined as follows:

Public WithEvents OrderQuery As CacheControl

I also have a procedure that is being called by windows every few seconds.
This is being accomplished via the Windows SetTimer function.

Now, the problem. The OrderQuery object gets events from an external
application. In the event procedure I update some state vars and return.
Then, in the timer callback I react to those events. There is a reason I'm
not doing it in the event itself, trust me on that part. The callback then
makes calls to the application in order to react to the messages it is
processing. This is where the problem comes in. When those messages are
sent the application is sending messages back (via the event procedure) in
response (as well as other ongoing messages). It appears that these two
procedures are interrupting each other and that is causing issues related to
program and variable state.

In C++ I'd use a CriticalSection to lock up the context while I was in those
two areas. I can't seem to find such a thing in VBA.

Notes:
I didn't write the external app and have no control over its design.
I'd really rather not write an ActiveX object (or any other type of external
object) to deal with this.

Any and all help would be greatly appreciated.

Thanks,

Mike