ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable UserForm 'X' Close Button (https://www.excelbanter.com/excel-programming/408257-disable-userform-x-close-button.html)

dimm

Disable UserForm 'X' Close Button
 
Hi again,

I hope everyone is keeping well.

I'm wondering if there is any way to disable or remove the X button on the
top right of a UserForm?

Mike

Disable UserForm 'X' Close Button
 
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
Exit Sub
End If
End Sub

"dimm" wrote:

Hi again,

I hope everyone is keeping well.

I'm wondering if there is any way to disable or remove the X button on the
top right of a UserForm?


Jon Peltier

Disable UserForm 'X' Close Button
 
Instead of just canceling, why not have it run the code in your cancel
button. That's why the user clicked the X anyway, right?

Assuming the cancel button is named btnCancel:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
btnCancel
End If
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Mike" wrote in message
...
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
Exit Sub
End If
End Sub

"dimm" wrote:

Hi again,

I hope everyone is keeping well.

I'm wondering if there is any way to disable or remove the X button on
the
top right of a UserForm?





All times are GMT +1. The time now is 01:32 AM.

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