Microsoft Office Tutorials and References
In Depth Information
A Resizable UserForm
Figure 15-20: VBA code converts Label control movements into new Width and Height properties for the
UserForm.
More VBA code is needed to adjust the controls in the UserForm when the UserForm size is
changed. The location for this new code is in the objResizer_MouseMove event-handler
procedure. The statements that follow do the job:
‘ Adjust the ListBox
On Error Resume Next
With ListBox1
.Width = Me.Width - 22
.Height = Me.Height - 100
End With
On Error GoTo 0
‘ Adjust the Close Button
With CloseButton
.Left = Me.Width - 70
.Top = Me.Height - 54
End With
These two controls are adjusted relative to the UserForm’s size (that is, Me ). After adding this
new code, the dialog box works like a charm. The user can make it as large as needed, and the
controls adjust.
It should be clear that the most challenging part of creating a resizable dialog box is figuring out
how to adjust the controls. When you have more than two or three controls, things can get very
complicated.
 
Search JabSto ::




Custom Search