Word Hacks [Electronic resources]

Andrew Savikas

نسخه متنی -صفحه : 162/ 25
نمايش فراداده

Hack 4 Create Custom Views

You can easily get a bit disoriented as you change views, toolbars, and zoom levels within Word. This hack shows how to create predefined views and return to them instantly.

Word offers a multitude of viewing options. With the addition of Reading Layout view in Word 2003, you can now choose from six different views: Normal, Web Layout, Print Layout, Reading Layout, Outline, and Print Preview. Plus, you can turn on and off features such as paragraph marks, tabs, hidden text, field codes, and bookmarks, just to name a few. And as Word has more toolbars than you can fit on most screens, depending on the work you're doing you may want to change your view a few dozen times each day.

Even if you only occasionally zoom in or out, or use Reading Layout or an extra toolbar here and there, you've probably found that there are a handful of viewing combinations that you prefer. Unfortunately, reorienting Word the way you want is no small feat. While it may not eat up a whole morning, a few seconds here and there to change a few settings can really add up.

To get the layout just the way you like it in a snap, you can create named sets of viewing options using some VBA code and add them to the View menu for quick toggling.

2.3.1 The Code

Say you like to do your editing in Word under the following conditions:

Normal view

Zoom to 120%

Only Standard, Formatting, and Reviewing toolbars visible

Field shading, paragraph marks, and hidden text visible

Revision tracking turned on

To make this configuration instantly available, put the following macro, named SetEditingView, in the template of your choice [Hack #50] . It sets all the viewing options listed above.

Sub SetEditingView( )
On Error Resume Next
Dim win As Window
Dim cbar As CommandBar
Dim sToolbarsToShow As String
' List toolbars to display
' All others will be hidden
sToolbarsToShow = "/Menu Bar/Standard/Formatting/Reviewing/"
' Hide any toolbars that aren't in the list
For Each cbar In Application.CommandBars
If InStr(sToolbarsToShow, "/" & cbar.Name & "/") Then
cbar.visible = True
Else
cbar.visible = False
End If
Next cbar
' Change the View settings
Set win = Application.ActiveWindow
With win
.View.Type = wdNormalView
.View.Zoom = 120
.View.FieldShading = wdFieldShadingAlways
.View.ShowParagraphs = True
.View.ShowHiddenText = False
End With
' Turn on revision tracking
ActiveDocument.TrackRevisions = True
End Sub

2.3.2 Putting the New View on the View Menu

Now you can create a new submenu on the View menu and add the new Editing view to it.

Select ToolsCustomize and click the Commands tab. In the Categories column, scroll down to New Menu and then select New Menu again from the Commands column, as shown in Figure 2-7.

Figure 2-7. Selecting a new menu to drag to the View menu

Next, drag the New Menu item to the View menu (when you drag the item over View on the main menu bar, the View menu will open) and drop it just under Outline view, as shown in Figure 2-8.

Figure 2-8. Placing the new menu on the View menu

After you place the new menu, right-click it, rename it "My Views," and select the option "Begin a new group."

Go back to the Customize dialog, click the Commands tab, and select Macros from the Categories column. From the Commands column, drag the SetEditingView macro to the new My Views menu. Then right-click it and rename it "Editing." Close the Customize dialog.

To run the macro, which will set the desired view options, just select it from the new My Views menu, as shown in Figure 2-9.

Figure 2-9. Selecting from the new My Views menu