Option Explicit
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_STYLE As Long = (-16)
Public Const WS_MAXIMIZEBOX As Long = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Public Sub MinMax(sCaption As String)
Dim hWndForm As Long
Dim iStyle As Long
If Val(Application.Version) < 9 Then
hWndForm = FindWindow("ThunderXFrame", sCaption) 'XL97
Else
hWndForm = FindWindow("ThunderDFrame", sCaption) 'XL2000
End If
iStyle = GetWindowLong(hWndForm, GWL_STYLE)
iStyle = iStyle Or WS_MAXIMIZEBOX
iStyle = iStyle Or WS_MINIMIZEBOX
SetWindowLong hWndForm, GWL_STYLE, iStyle
End Sub
Public Sub Example()
UserForm1.Show vbModal
End Sub