Run Time Error on Closing UserForm

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
 
L

Leith Ross

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top