jimmy2timez
New Member
- Joined
- Apr 21, 2010
- Messages
- 48
Is there a "simple" code that allows a userform to be resized after it is open?
Is there a "simple" code that allows a userform to be resized after it is open?
Me.Width = 115
frmRename.Width = 115
Private Sub UserForm_Activate()
MakeFormResizable
End Sub
'Written: August 02, 2010
'Author: Leith Ross
'Summary: Makes the UserForm resizable by dragging one of the sides. Place a call
' to the macro MakeFormResizable in the UserForm's Activate event.
Private Declare Function SetLastError _
Lib "kernel32.dll" _
(ByVal dwErrCode As Long) _
As Long
Public Declare Function GetActiveWindow _
Lib "user32.dll" () As Long
Private Declare Function GetWindowLong _
Lib "user32.dll" Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) _
As Long
Private Declare Function SetWindowLong _
Lib "user32.dll" Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) _
As Long
Public Sub MakeFormResizable()
Dim lStyle As Long
Dim hWnd As Long
Dim RetVal
Const WS_THICKFRAME = &H40000
Const GWL_STYLE As Long = (-16)
hWnd = GetActiveWindow
'Get the basic window style
lStyle = GetWindowLong(hWnd, GWL_STYLE) Or WS_THICKFRAME
'Set the basic window styles
RetVal = SetWindowLong(hWnd, GWL_STYLE, lStyle)
'Clear any previous API error codes
SetLastError 0
'Did the style change?
If RetVal = 0 Then MsgBox "Unable to make UserForm Resizable."
End Sub
Private Sub ZoomComboBox_Change()
Form.Zoom = Form.ZoomComboBox.Value
Form.Height = Form.ZoomComboBox.Value / 100 * 500
Form.Width = Form.ZoomComboBox.Value / 100 * 600
End Sub