The Problem:
Call me weird, but I've taken to editing in Print Preview. But it takes three steps to switch to Print Preview, enter Edit mode, and zoom the window how I want it. I'd like to make it one step.
The Solution:
Easy enough. Actually, this is a good candidate for a recorded macro. Choose Tools » Macro » Record Macro, type a name (for example, PrintPreviewEdit
), type a description, and then click the OK button. Choose File » Print Preview, and click the Magnifier button to enter editing mode. Choose View » Toolbars » Print Preview to toggle off the Print Preview toolbar (to save the space it takes up). Choose View » Zoom, select your preferred zoom settings, and click the OK button. Click the Stop Recording button on the Stop Recording toolbar to stop the Macro Recorder.
If you open the macro in the Visual Basic Editor, it should look something like Example 8-2.
Here's what's going on in this macro:
-
The
ActiveDocument.PrintPreview
statement technically applies thePrintPreview
method to theActiveDocument
object. TheActiveDocument
object represents the active documentthat is, the document you're working with in the user interface. Amethod
is a command or action that you can take with an object. -
The
CommandBars("Print Preview").Visible = False
statement turns off the display of the Print Preview toolbar. ACommandBar
object is either a toolbar (as it is here) or a menu bar. VBA groups similar objects into groups calledcollections
to simplify access to them. To reach an object in a collection, you specify its name (as here: the object called "Print Preview" in theCommandBars
collection) or its index number (for example,CommandBars(1)
indicates the object with the index number 1 in theCommandBars
collection). Objects have properties (attributes) that control how they behave. This statement sets theVisible
property of theCommandBar
object toFalse
, making it invisiblein other words, hiding the toolbar. -
With... End With
is a structure for applying multiple methods, properties, or a combination of the two to the same object. By using aWith
statement, you tell VBA that you're referring to a particular object until you start referring to another object. (This enables VBA to work faster than if it has to work out the target object each time.) ThisWith
statement works with theZoom
object contained in theView
object within theActivePane
object (the active pane) within theActiveWindow
object. The statements contained in theWith
statement set the number of page columns to2
and the number of page rows to1
in other words, the equivalent of clicking the Many Pages button in the Zoom dialog box and choosing two pages wide by one page deep.
Macro to open Print Preview in editing mode
Example 8-2
Sub PrintPreviewEdit() ' PrintPreviewEdit Macro ' Macro recorded 5/14/2005 by Teresa Ramirez ActiveDocument.PrintPreview ActiveDocument.ActiveWindow.View.Magnifier = False CommandBars("Print Preview").Visible = False With ActiveWindow.ActivePane.View.Zoom .PageColumns = 2 .PageRows = 1 End With End Sub
If you want this macro to supplant the built-in Print Preview command, rename it FilePrintPreview
. You cannot record a macro with the name of a built-in command, but you can rename a recorded macro in the Visual Basic Editor so that it replaces a built-in command.You can also create a macro with the name of a built-in command by working in the Visual Basic Editor. A quick way to start such a macro is to press Alt+F8 to display the Macros dialog box, choose "Word Commands" in the "Macros in" drop-down list, select the command you want to replace, choose "Normal.dot" in the "Macros in" drop-down list, and then click the Create button. Word enters the code equivalent to the command in the Visual Basic Editor, providing a good starting point.