MS Word

Make Print Preview Open in Editing Mode

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 the PrintPreview method to the ActiveDocument object. The ActiveDocument object represents the active documentthat is, the document you're working with in the user interface. A method 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. A CommandBar object is either a toolbar (as it is here) or a menu bar. VBA groups similar objects into groups called collections to simplify access to them. To reach an object in a collection, you specify its name (as here: the object called "Print Preview" in the CommandBars collection) or its index number (for example, CommandBars(1) indicates the object with the index number 1 in the CommandBars collection). Objects have properties (attributes) that control how they behave. This statement sets the Visible property of the CommandBar object to False, 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 a With 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.) This With statement works with the Zoom object contained in the View object within the ActivePane object (the active pane) within the ActiveWindow object. The statements contained in the With statement set the number of page columns to 2 and the number of page rows to 1 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.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 "" 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.

by BrainBellupdated