I’ve got a routine that I am calling which, depending on the server’s availability, can take virtually no time at all or up to 10 or 20 seconds to run. I don’t want the user to worry that the process isn’t happening, so I would like to indicate that the process is in progress. I don’t find manipulating the status bar obvious enough to users, so I thought about displaying a dialog box while the process runs. Two problems I encountered…one, I don’t want the user to close the dialog box on their own, but can’t seem to figure out how to do this. For the form I am just using this code, hoping that it would just beep if they tried to close it (but of course that isn’t what happens!):
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Beep
End If
End Sub
I’m not even sure that it is possible to prevent the user from closing the dialog box, or if it is actually even desireable! But I can’t think of another way to display an ‘in progress’ type message!
And my second problem is that while I am showing the dialog box before calling the code, and unloading after the code runs, it doesn’t seem to want to unload unless I click the ‘X’ on the dialog box and close it. The code I am using is:
Userform.Show
‘Run process
If ProcessRuns Then
…
Else
…
End If
Unload UserForm
I thought about using a Do While type statement here instead. Maybe this would work better.
And finally, if the dialog box turns out to be the way to go, does anyone know how to animate it so the user knows it hasn’t hung? Either something flashing, or a moving icon, or something like that?
Thanks so much for your time and help!