Microsoft Office Tutorials and References
In Depth Information
Zooming and Scrolling a Sheet from a UserForm
Me.Height = SmallSize
OptionsButton.Caption = “Options >>”
End If
End Sub
This procedure examines the Caption of the CommandButton and sets the UserForm’s Height
property accordingly.
When controls aren’t displayed because they’re outside the visible portion of the
UserForm, the accelerator keys for such controls continue to function. In this example,
the user can press the Alt+L hot key (to select the Landscape mode option) even if that
option isn’t visible. To block access to nondisplayed controls, you can write code to
disable the controls when they aren’t displayed.
The example in this section is available on the companion CD-ROM. The file is named
change userform size.xlsm .
Zooming and Scrolling a Sheet from a UserForm
The example in this section demonstrates how to use ScrollBar controls to allow sheet
scrolling and zooming while a dialog box is displayed. Figure 14-7 shows how the example dialog box
is set up. When the UserForm is displayed, the user can adjust the worksheet’s zoom factor (from
10% to 400%) by using the ScrollBar at the top. The two ScrollBars in the bottom section of the
dialog box allow the user to scroll the worksheet horizontally and vertically.
This example, named zoom and scroll sheet.xlsm , is available on the companion
If you look at the code for this example, you’ll see that it’s remarkably simple. The controls are
initialized in the UserForm_Initialize procedure, which follows:
Private Sub UserForm_Initialize()
LabelZoom.Caption = ActiveWindow.Zoom & “%”
‘ Zoom
With ScrollBarZoom
.Min = 10
.Max = 400
.SmallChange = 1
Search JabSto ::

Custom Search