Microsoft Office Tutorials and References
In Depth Information
Changing a UserForm’s Size
Refer to Chapter 15 for an example that allows the user to change the UserForm’s size
by dragging the lower-right corner.
Figure 14-5 shows the dialog box as it is first displayed, and Figure 14-6 shows it after the user
clicks the Options button. Notice that the button’s caption changes, depending on the size of the
Figure 14-5: A sample dialog box in its standard mode.
Figure 14-6: The same dialog box enlarged to show some options.
While you’re creating the UserForm, set it to its largest size to enable you to work with the
controls. Then use the UserForm_Initialize procedure to set it to its default (smaller) size.
The code uses two constants, defined at the top of the module:
Const SmallSize As Integer = 124
Const LargeSize As Integer = 164
This example displays a list of worksheets in the active workbook and lets the user select which
sheets to print. Following is the event handler that’s executed when the CommandButton named
OptionsButton is clicked:
Private Sub OptionsButton_Click()
If OptionsButton.Caption = “Options >>” Then
Me.Height = LargeSize
OptionsButton.Caption = “<< Options”