In the userform code module have this code:
Option Explicit
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Sub UserForm_Activate()
DisableCloseButton GetActiveWindow()
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
In a normal code module have this code:
Option Explicit
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" _
(ByVal hMenu As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" _
(ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) _
As Long
Private Const MF_BYPOSITION = &H400
Private Const MF_REMOVE = &H1000
Sub DisableCloseButton(hWnd As Long)
Dim hMenu As Long
Dim menuItemCount As Long
hMenu = GetSystemMenu(hWnd, 0)
If hMenu Then
menuItemCount = GetMenuItemCount(hMenu)
RemoveMenu hMenu, _
menuItemCount - 1, _
MF_REMOVE Or MF_BYPOSITION
DrawMenuBar hWnd
End If
End Sub
Sub LoadForm()
Load UserForm1
UserForm1.Show
End Sub
RBS