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.
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:
ActiveDocument.PrintPreviewstatement technically applies the
PrintPreviewmethod to the
ActiveDocumentobject represents the active documentthat is, the document you're working with in the user interface. A
methodis a command or action that you can take with an object.
CommandBars("Print Preview").Visible = Falsestatement turns off the display of the Print Preview toolbar. A
CommandBarobject is either a toolbar (as it is here) or a menu bar. VBA groups similar objects into groups called
collectionsto simplify access to them. To reach an object in a collection, you specify its name (as here: the object called "Print Preview" in the
CommandBarscollection) or its index number (for example,
CommandBars(1)indicates the object with the index number 1 in the
CommandBarscollection). Objects have properties (attributes) that control how they behave. This statement sets the
Visibleproperty of the
False, making it invisiblein other words, hiding the toolbar.
With... End Withis a structure for applying multiple methods, properties, or a combination of the two to the same object. By using a
Withstatement, 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.) This
Withstatement works with the
Zoomobject contained in the
Viewobject within the
ActivePaneobject (the active pane) within the
ActiveWindowobject. The statements contained in the
Withstatement set the number of page columns to
2and the number of page rows to
1in 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
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.