Run Time Error on Closing UserForm

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hello,
I have a userform with a cancel button on it. If I select that button, the
program ends as it is supposed to. However, if I select the red X in the
upper right hand side, I get the following (which occurs at userform.hide):

Run Time Error '-2147418105 (800100007)'

Automation Error

The callee (server [not server application] is not available and
disappeared; all connections are invalid. The call may have executed.



Any ideas? I did had a button that calls another userform for information,
but then that is closed and it comes back to this one.



Thanks,



Bill
 
Hello Bill,

You can determine which close button was chosen and skip UserForm.Hide
if it was the window close button (red X). This information is made
available in the UserForm_QueryClose event.

Here is an example...


Code:
--------------------

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

If CloseMode = 0 Then Exit Sub 'Red X was clicked
UserForm1.Hide

End Sub

--------------------


If the user clicks your close button, CloseMode will equal 1.

Sincerely,
Leith Ross
 
Back
Top