close msgbox with VBA code

J

Jay Jacobs

I have an app that times out if inactive greater than 5 minutes.
Occasionally it is hung up by one of many messageboxes that does not close
when the app times out. I have found solutions for vbinformation or
vbcritical, however, what is the best way to code the messagebox to close
when it is a vbyes vbno or one with multiple choices?

Thanks
Jay
 
D

Douglas J. Steele

Depending on your exact situation, it can be done using the FindWindow and
SendMessage APIs.

Karl E. Peterson has an example at
http://vb.mvps.org/samples/project.asp?id=TimedMsg that works fine in
Access.

One caveat, though: the message box MUST have a Cancel button on it for this
to work. If you've only got Yes and No buttons, for instance, it will not
work.
 
Top