Microsoft Office Tutorials and References
In Depth Information
Windows collection by using the Caption value instead of an index number. The following
code fragment assigns the string "My Window" to the Caption property of the active window,
and then invokes the ActiveSheet object’s Calculate method to recalculate all of the formulas
on the active sheet in MyWindow .
ActiveWindow.Caption = "My Window"
The best use of the ActiveWindow object is to control the zoom level of the window or move
the window to display a particular cell. The ScrollRow and ScrollColumn properties provide
the cell that’s in the upper-left corner.
The following example illustrates how to use the ScrollColumn , ScrollRow , and Zoom
properties. The example enters text into cell H18 using a 4-point font size, too small to read at Zoom
levels below 200 percent. The macro then increases the Zoom level to the maximum of 400%
and positions the window so that cell H18 is in the upper-left corner.
ActiveCell.Font.Size = 4
ActiveCell.Value = "This text is very small and hard to read."
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollRow = 16
ActiveWindow.Zoom = 100
MsgBox "Click OK to zoom in to read", vbOKOnly + vbInformation, _
"Programming Microsoft Excel Inside Out"
ActiveWindow.Zoom = 400
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollRow = 18
The next two macros can be assigned to buttons to allow one-click access to zoom in or out.