Untuk bisa menambahkan tombol Minimize dan Maximize di UserForm Excel, caranya adalah sebagai berikut:
Buka aplikasi Microsoft Visual Basic for Application pada Excel, bisa melalui tab developer ataupun bisa juga dengan menekan tombol Alt+F11.
Tambahkan sebuah UserForm dan kemudian masukkan script VBA berikut ini ke dalam UserForm1 (Code).
Code
Private Sub UserForm_Activate()
AddMinMaxButton Me.Caption, MinButton:=True, MaxButton:=True
End Sub
Tambahkan sebuah Module dan masukkan script VBA berikut ke dalam Module1 (Code).
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const GWL_STYLE = (-16)
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 Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Public Sub AddMinMaxButton(ByVal FormCaption As String, _
ByVal MinButton As Boolean, ByVal MaxButton As Boolean)
Dim hWnd As Long
Dim lngStyle As Long
hWnd = FindWindow(vbNullString, FormCaption)
lngStyle = GetWindowLong(hWnd, GWL_STYLE)
If MaxButton Then
lngStyle = lngStyle Or WS_MAXIMIZEBOX
End If
If MinButton Then
lngStyle = lngStyle Or WS_MINIMIZEBOX
End If
SetWindowLong hWnd, GWL_STYLE, lngStyle
DrawMenuBar hWndEnd Sub
Sumber : http://blog.belajarexcel.org/excel-macro/menambahkan-tombol-minimize-dan-maximize-di-userform/
@masbaim - your partner
We are on
menu-navbar