ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run Time Error on Closing UserForm (https://www.excelbanter.com/excel-programming/367297-run-time-error-closing-userform.html)

Bill[_30_]

Run Time Error on Closing UserForm
 
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



Leith Ross[_656_]

Run Time Error on Closing UserForm
 

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


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=561736



All times are GMT +1. The time now is 12:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com