by Selva V Pasupathy
The following lines of codes will help add a minimize button on a userform which will be handy in many situations.
First copy the following 3 lines of codes to userform code window.
Private Sub UserForm_Initialize()
Call FormatUserForm(Me.Caption)
End Sub
Copy the following code in a module.
Option Explicit
Private Declare Function _
FindWindowA Lib "USER32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function _
GetWindowLongA Lib "USER32" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function _
SetWindowLongA Lib "USER32" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Sub FormatUserForm(UserFormCaption As String)
Dim hWnd As Long
Dim exLong As Long
hWnd = FindWindowA(vbNullString, UserFormCaption)
exLong = GetWindowLongA(hWnd, -16)
If (exLong And &H20000) = 0 Then
SetWindowLongA hWnd, -16, exLong Or &H20000
Else
End If
End Sub
Sub ShowForm()
UserForm1.Show
End Sub
For some more resources visit
- http://selvavinaygam.googlepages.com/
- More Resources
- Demo Workbooks
- Distill Hyperlinks
- Few VBA Tips
- VB DEVELOPER REFERENCE
-Selva V Pasupathy
HSBC Global Resourcing
Hyderabad, India
Contents of this Site « Selva’s Blog said
[...] Add Minimize Button to Userform [...]