Option Explicit
Private Declare Function GetSystemMenu Lib "USER32" _
(ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "USER32" _
(ByVal hme2nu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Private Declare Function FindWindowA Lib "USER32" _
(ByVal lpClassName2 As String, _
ByVal lpWindowName2 As String) As Long
Private Const MF_BYPOSITION As Long = &H400
Public Sub FormatUserForm(UserFormCaption As String)
Dim lFrmHdl As Long
Dim iCount As Integer
lFrmHdl = FindWindowA(vbNullString, UserFormCaption)
If lFrmHdl <> 0 Then
For iCount = 0 To 1
RemoveMenu GetSystemMenu(lFrmHdl, False), 0, MF_BYPOSITION
Next iCount
End If
End Sub
Sub ShowForm()
UserForm1.Show
End Sub
Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Call FormatUserForm(Me.Caption)
End Sub
|