Hi kosherboy
Disable the X button. Here's some Code from our own Leith Ross to do so.
VBA Module Code:
'Written: January 09, 2010
'Author: Leith Ross
'Summary: Disables the Close X on a UserForm and dims it.
Public Declare Function GetSystemMenu _
Lib "user32.dll" _
(ByVal hwnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function DrawMenuBar _
Lib "user32.dll" _
(ByVal hwnd As Long) As Long
Private Declare Function DeleteMenu _
Lib "user32.dll" _
(ByVal hwnd As Long, _
ByVal nPosition As Long, _
ByVal uflags As Long) As Long
Private Declare Function GetForegroundWindow _
Lib "user32.dll" () As Long
Sub DisableCloseBox()
Const MF_BYCOMMAND As Long = &H0&
Const SC_CLOSE As Long = &HF060
Const SC_MAXIMIZE As Long = &HF030
Const SC_MINIMIZE As Long = &HF020
Const SC_RESTORE As Long = &HF120
Dim hMenu As Long
Dim hwnd As Long
Dim Ret As Long
hwnd = GetForegroundWindow()
hMenu = GetSystemMenu(hwnd, 0&)
Ret = DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND)
Ret = DrawMenuBar(hwnd)
End Sub
'UserForm Event Code
Code:
Private Sub UserForm_Activate()
DisableCloseBox
End Sub
Bookmarks