ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   I need to disable to X on a user form (https://www.excelbanter.com/excel-discussion-misc-queries/19386-i-need-disable-x-user-form.html)

cwwolfdog

I need to disable to X on a user form
 
I can't figure out how to prevent someone from clicking the close (X) icon on
a user form. I have a cancel button which is what I want them to have to use.

thanks

Dave Peterson

How about:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Beep
'msgbox "doesn't work"
Cancel = True
End If
End Sub

cwwolfdog wrote:

I can't figure out how to prevent someone from clicking the close (X) icon on
a user form. I have a cancel button which is what I want them to have to use.

thanks


--

Dave Peterson

cwwolfdog

Thanks Dave,

Worked like a charm.

"Dave Peterson" wrote:

How about:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Beep
'msgbox "doesn't work"
Cancel = True
End If
End Sub

cwwolfdog wrote:

I can't figure out how to prevent someone from clicking the close (X) icon on
a user form. I have a cancel button which is what I want them to have to use.

thanks


--

Dave Peterson



All times are GMT +1. The time now is 10:47 PM.

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