Option Explicit
'////////////////////////////////////////////////////////////
'// What you need to do is to Disable the System Menu itime
'// for the Move control.
'// The system menu or Control menu is the Dropdown list you
'// get when you Right click on the windows Top area or write
'// to Area that usually has the Window caption, in this case
'// the userforms Name caption. Std windows has six, Userforms
'// have 2 = Move & Close.
'// Intersetingly enought to disable the close button all you
'// need to add to this routine to Disable Move is to Loop
'// until you hit the close = 7 ? and NOT 6, this I believe
'// takes into account the instance where the Sytem menu has
'// a "Whats this button"
'////////////////////////////////////////////////////////////
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 Declare Function FindWindowA _
Lib "user32" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Long
Private Const MF_BYPOSITION As Long = &H400
Private Sub UserForm_Initialize()
Dim lFrmHdl As Long, iCount As Integer
'// Ivan F Moala
lFrmHdl = FindWindowA(vbNullString, Me.Caption)
If lFrmHdl <> 0 Then
'// MF_BYCOMMAND
'//Indicates that uPosition gives the identifier of the menu item.
'//If neither the MF_BYCOMMAND nor MF_BYPOSITION flag is specified,
'//the MF_BYCOMMAND flag is the default flag.
'// MF_BYPOSITION
'//Indicates that uPosition gives the zero-based relative position of the menu item.
'// ie 0,1,2,3 etc
'Exit Sub
'//Typical Windows has 6 menus
'//Restore, Move, Size, Minimise, Maximize, Close
'//Even though a Userform displays 2 = Move & Close
'//By default Move is the Next item
'//so just loop twice
For iCount = 0 To 1
RemoveMenu GetSystemMenu(lFrmHdl, False), 0, MF_BYPOSITION
Next iCount
End If
End Sub