Form with no Cancel option
I would go with the QueryClose approach as others have suggested.
FWIW you could grey out and disable the X-button -
Option Explicit
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName$, _
ByVal lpWindowName$) As Long
Private Declare Function RemoveMenu Lib "user32" _
(ByVal hMenu&, ByVal nPosition&, ByVal wFlags&) As Long
Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hWnd&, ByVal bRevert&) As Long
Private Const SC_CLOSE = &HF060&
Private Sub UserForm_Initialize()
Dim hWnd As Long, hMenu As Long
hWnd = FindWindow("ThunderDFrame", Me.Caption)
hMenu = GetSystemMenu(hWnd, 0)
RemoveMenu hMenu, SC_CLOSE, 0
End Sub
' make sure you have a way to close the form
Private Sub CommandButton1_Click()
Unload Me
End Sub
Regards,
Peter T
"Anne Schouten" wrote in message
...
I made an Excelform.
If a user closes the form with the X-button (Cancel) at the top righthand
corner, other macro's will give problems, so I dont want the form to be
closed with this button.
In Access you can hide this button, but so far I can see that is not
possible in Excel. How can I prevent that the user uses this Cancelbutton?
Anne
|