Not really sure this what you want but here is a macro that will allow you to resize the UserForm by dragging any one of the sides. The code is do this is rather complex, but I have done that part for you. You only need to call the macro MakeFormResizable from the UserForm's Activate event code.
Calling the Macro from the UserForm
Private Sub UserForm_Activate()
Macro Module Code
'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) _
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) _
Private Declare Function SetWindowLong _
Lib "user32.dll" Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) _
Public Sub MakeFormResizable()
Dim lStyle As Long
Dim hWnd As Long
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
'Did the style change?
If RetVal = 0 Then MsgBox "Unable to make UserForm Resizable."
Hi I tried to use this code with form in access, unfortunately it doesn't seem to be working
I am a beginner with VBA and need a code that can be used to resize a userform in access at runtime using mouse events.
I never thought I would learn enough about Excel to contribute to this forum, but here goes ...
I believe it to be worth noting that to increase the number of characters of text which can be displayed in a UserForm progress bar window, it is insufficient to make the window wider with (for example) 'UserForm.Width = Application.Max(UserForm.Width, Application.UsableWidth / 3)'.
One must also make the UserForm.Label field wider with (for example) 'UserForm.Label.Width = Application.Max(UserForm.Label.Width, UserForm.InsideWidth * 0.9)'. The UserForm.Label field is, of course, the field in which text gets displayed within the UserForm window.
When making the UserForm.Label field wider, it also makes sense to make the ProgressBar field just as wide with (for example) 'UserForm.ProgressBar.Width = Application.Max(UserForm.ProgressBar.Width, UserForm.Label.Width)'.
It is a crying shame that one can't find this kind of advice in Microsoft's Excel VBA documentation!
Bill, thanks for hosting MrExcel.com! It is an incredibly valuable resource! I would never have been able to learn Excel VBA without it.
It is a historical thread, but I tested your code to make form resizable (for 64 bit) but I did not succeed making it work.
I adapted the functions declaration and replaced GetWindowLong and SetWindowLong with GetWindowLongPtrA and SetWindowLongPtrA but the form is not resizable...
lStyle and RetVal both are -1798832000.
Did you try this solution for 64 bit?
Is it a way to make it working?