Home Forums Programming General How to Automate the closing of a window? RE: How to Automate the closing of a window?

  • Sue_H - Tuesday, December 12, 2017 7:20 AM

    sqlnoob2015 - Monday, December 11, 2017 12:36 PM

    What is the best way to automate the clearing out of an error message that pops up a few times a day in Excel?

    Basically every now and then I get a "deadlock error" which causes a small window to pop up on the screen.  Someone then has to go in and click OK and then refresh to resume the Excel process.  

    No need to get into the deadlock issue.  We know what is causing it but still want to find a work around.   

    I'm trying to find a windows macro, VBA marco or something similar that will detect when this message comes up and OK's past it to resume the auto-refresh process in Excel.     

    What is the best way to go about this?

    If the message box has the focus then I would guess a macro in the app itself isn't going to be of much use. That's part of the reason that unattended processing like that with Excel isn't supported.
    It seems that something would need to be incorporated in whatever the Excel process is so look at whatever that code is kicking of the Excel process - use some type of error handling. Worst case would be doing something to simply ignore the error which often ends up in ignoring other crucial errors and making things worse. To do that in Excel, I believe it's something like Application.DisplayAlerts = False

    Sue

    Or skip the error display with On Error Resume Next before you make the call to the database.  The On Error syntax also allows you to trap the error and take some appropriate action if you wish.