Avatar of swjtx99
swjtx99

asked on 

Kill Excel Dialog Box (if it exists)

I am opening a file from a network drive, entering some data, then saving it with changes.

Randomly, the network will hang and a "uploading file to server...." dialog box will appear with a "cancel" button. What I want is if that box appears, autoclick the cancel button. The following code works, however, if that dialog box does not appear, sending the keystroke causes the next dialog box to be clicked through. I'd like to find a way to detect if the dialog box is there and only send the keystroke if it is.

Windows("MyFile.xlsx").Activate
Application.ScreenUpdating = False
Application.DisplayAlerts = False
ActiveWorkbook.Close savechanges:=True
Application.SendKeys ("~") ' this works fine unless the dialog box doesn't appear, then it clicks through the next dialog box.
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.DisplayAlerts = True
MsgBox ("Report Complete")
Microsoft Excel

Avatar of undefined
Last Comment
swjtx99

8/22/2022 - Mon