Private Const USERFORM_CLASSNAME = "ThunderDFrame"
Private Const GWL_STYLE = -16
Private Const WS_SYSMENU = &H80000
'// API関数宣言
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" ( _
ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" ( _
ByVal hwnd As Long) As Long
'// 以下イベントプロシージャ
Private Sub CommandButton1_Click()
' 自フォーム終了
Unload Me
End Sub
Private Sub U2serForm_Initialize()
Dim hwnd As Long
Dim lngRet As Long
' ウインドウハンドル取得(Excel2000)
hwnd = FindWindow(USERFORM_CLASSNAME, Me.Caption)
' ウインドウ属性取得
lngRet = GetWindowLong(hwnd, GWL_STYLE)
' ウインドウ属性変更(システムメニュー削除)
lngRet = SetWindowLong(hwnd, GWL_STYLE, lngRet And Not WS_SYSMENU)
End Sub