How to Open Word Documents with Specific Zoom and View
The Zoom dialog box which you can open via View tab > Zoom or by clicking the zoom percentage value in the bottom-right corner of the document window in Word includes a number of zoom options you can use to define how document pages are to be displayed and arranged on the screen. In addition, the Views group on the View tab of the Ribbon lets you select from a number of different view types.
This article explains how the different zoom and view options work and provides information about how to manage the zoom and view settings via VBA macros.
You will find macros ready for use that will force Word to open new or existing documents with a specific zoom or view plus a couple of other macro examples. You will also find information that can help you modify the macros to open with precisely the zoom and view type you want. You can also set up the macros so you can easily run them whenever you want.
As described in the article How To Open Word Documents With A Specific Zoom And View, Word 2010 and earlier versions let you manage how individual documents open without using macros. In Word 2013 and later versions this is no longer possible. Therefore, the macros are especially useful in Word 2013 and later versions but they can be useful in earlier Word versions too.
How to name macros so they will run automatically when you create, open or close a Word document
In order to use macros to set the zoom and view of new documents and existing documents you open in Word, you can take advantage of the macro naming rules listed below. Note that the macro names must be written exactly as shown below.
Macros in the Normal.dotm template
This means that macros in Normal.dotm named AutoNew, AutoOpen or AutoClose work globally on any Word document. The AutoClose macro name will not be used here but is listed for completeness.
Macros in other Word templates
This means that macros named AutoNew, AutoOpen or AutoClose in another template than Normal.dotm only affect documents based on that specific template. The AutoClose macro name will not be used here but is listed for completeness.
Zoom and View in VBA operates on the View of document windows
In order to set or return the zoom and view of a Word document via VBA, you must tell Word which document window you refer to. If a window has been split in two panes, the examples below will apply to the active pane. You could also refer directly to a specific pane. Examples:
Example 1 - Refer to the View of the currently active window
With ActiveDocument.ActiveWindow.View
'Do something with the view and zoom
End With
Example 2 - Refer to the View of a specific window of a specific document
With Documents("MyDocument.docx").Windows(1).View
'Do something with the view and zoom
End With
Zoom types you can use in macros
The Zoom dialog box in Word lets you select the zoom in different ways. The macros provided in this article show examples of how to set the zoom via VBA.
In the table below, you will find a list of the wdZoom constants and the related values you can use in macros to set the zoom to any of the zoom types you can apply directly via the Zoom dialog box or related commands in the Word user interface:
Options in Zoom dialog box | VBA .View... | More details |
---|---|---|
Percent -200%, 100%, 75% or custom value in the range 10-500. Result: | .Zoom.Percentage = [value] | Works with any View type. Type in VBA: Long Decimal values are rounded |
Page width Result: | .Zoom.PageFit = wdPageFitBestFit | Works only with Print Layout view and Print Preview. When using wdPageFitBestFit, the zoom percentage is automatically recalculated every time the document window size is changed. wdPageFitNone does not change the zoom. |
Text width Result: | .Zoom.PageFit = wdPageFitTextFit | Works only with Print Layout view and Print Preview. |
Whole page Result: | .Zoom.PageFit = wdPageFitFullPage | Works only with Print Layout view and Print Preview |
Many pages Result: Note: If you don't specify a number of pages across, Word will show as many pages as the window size and zoom allows. You can force Word to show only 1 page across by selecting 1x1 or 2x1. | .Zoom.PageRows = [value] | Works only with Print Layout view and Print Preview. .PageColumns defines the number of pages across, i.e. side by side. .PageRows defines the number of pages down. Type in VBA: Long Since the lowest possible zoom percentage is 10, the number of columns shown will never be higher than the number of pages that can be shown across with zoom 10%. See also the note in the leftmost column. |
View types you can use in macros
In the table below, you will find a list of the wdViewType constants and the related values you can use in macros to set the view type to any of the view types you can apply directly in the Word user interface:
View selected the Word user interface | Value | VBA - wdViewType |
---|---|---|
View tab > Draft (or Normal) | 1 | wdNormalView |
View tab > Outline | 2 | wdOutlineView |
View tab > Print Layout | 3 | wdPrintView |
Print Preview as in Word before the Backstage was implemented. | 4 | wdPrintPreview |
Related to master documents and subdocuments. The view type is not listed directly on the View tab. However, this view type is automatically selected for a master document if you select Outline view and click the Show document command on the Outline tab in the Ribbon. | 5 | wdMasterView |
View tab > Web Layout | 6 | wdWebView |
View tab > Read Mode (or Full Screen Reading) | 7 | wdReadingView |
Cannot be selected via the user interface. Related to conflicts in relation to co-authoring (Word 2010 and later) | 8 | wdConflictView |
How to set the window size in a macro
If you want, you can also add code in the macros that set the window size. Such code is not included in the macros below. Note that the window you operate on must be active.
Maximizing a window in a macro
Application.WindowState = wdWindowStateMaximize
Minimizing a window in a macro
Set the window size to a custom size
Application.WindowState = wdWindowStateMinimize
Setting the active window to the most recently used custom size
The following line of code will set the active window to the most recently used custom size, i.e. a size that is not maximized and not minimized:
Application.WindowState = wdWindowStateNormal
Macros ready for use
In the macros below, you can modify the zoom based on the information found it the table in the section Zoom types you can use in macros. Also, you can replace the wdPrintView with another view type as listed in the table in the section View types you can use in macros.
Note that, in general, the view type is set first in the macros to prevent errors in case of settings that do not apply to all types of views.
Macros #1 - Open Word documents with 100 % zoom and Print Layout view
AutoNew and AutoOpen macros that DO NOT force only one page across the window
The following two macros will automatically set the zoom percentage to 100% and set the view type to Print Layout when you create new document or open existing documents. Note, however, that Word will display as many pages across, side by side, as the window has room for. With wide and high-resolution monitors and a maximized window, there will often be room for two pages across.
Note that the code in the AutoNew and AutoOpen macros is the same - only the macro name and the comment differ.
You can modify the zoom percentage and view type as desired. See the overviews above for help om which code to use. Delete the irrelevant line of code if you want to set only the zoom or view.
The macro code:
Sub AutoNew()
'Applies to new documents you create
With ActiveWindow.View
.Type = wdPrintView
.Zoom.Percentage = 100
End With
End Sub
Sub AutoOpen()
'Applies to existing documents you open
With ActiveWindow.View
.Type = wdPrintView
.Zoom.Percentage = 100
End With
End Sub
AutoNew and AutoOpen macros that DO force only one page across the window
The following two macros are like the ones above with the difference that a line of code has been added to set PageColumns to 1 and thereby force Word to show only 1 page across even if there is room for more in the actual document window. That is the setup I prefer.
The macro code:
Sub AutoNew()
'Applies to new documents you create
With ActiveWindow.View
.Type = wdPrintView
.Zoom.PageColumns = 1
.Zoom.Percentage = 100
End With
End Sub
Sub AutoOpen()
'Applies to existing documents you open
With ActiveWindow.View
.Type = wdPrintView
.Zoom.PageColumns = 1
.Zoom.Percentage = 100
End With
End Sub
Note that you can obtain the same result in different ways. Example:
'Another method to obtain Print Layout view, 100% zoom and 1 page across
With ActiveWindow.View
.Type = wdPrintView
.Zoom.PageFit =wdPageFitFullPage
.Zoom.Percentage = 100
End With
What to do if you don't want to set zoom and view automatically but only set the zoom and view on demand?
If you do not want to automatically apply zoom and view type when you create or open documents, you can use the same code as shown in the AutoNew and AutoOpen macros. You only need to name the macro differently, such as SetZoom100_PrintLayoutView or any other legal macro name of your liking.
You can add the macro to the Quick Access Toolbar and/or assign a keyboard shortcut to it for quick access.
Note that you can also add the AutoNew or AutoOpen macro to the Quick Access Toolbar and/or assign a keyboard shortcut to it for quick access. Then the macros will still run automatically and, in addition, you can apply the setting whenever you want.
Macro #2 - Display multiple pages down and across
The macro below is an example of how you can display multiple pages down and across, here 2 pages down and 3 pages across. The result is the same as selecting 2x3 in the Zoom dialog box > Many pages.
The macro code:
Sub PrintLayoutView_2PagesDown_3PagesAcross()
With ActiveWindow.View
.Type = wdPrintView
.Zoom.PageRows = 2
.Zoom.PageColumns = 3
End With
End Sub
Note that it does not necessarily make sense to specify both .PageRows and .PageColumns. When you set one of those values, it will indirectly influence the other value so they do not conflict.
Macro #3 - Draft view with style area pane displayed
In Draft view and Outline view, you can display an area to the left in the window that shows the style names of paragraphs. This is useful to keep track of the formatting. Note, however, that Word does not display style names in the style area pane in case of tables.
You can manually turn on the style area pane by setting a value in File > Options > Advanced > Display group > Style area pane in Draft and Outline views. See the illustrations below.
The illustration below shows the result of setting a width of the style area pane:
The macro below switches to Draft view and sets the style area pane width to 3 cm. When the style area pane is visible, you can manually drag the vertical divider to change its width. If you set the width to 0 (zero), the style area pane will not be shown.
The macro code:
Sub DraftView_ShowStyleAreaPane()
With ActiveDocument.ActiveWindow
.View.Type = wdNormalView
.View.Zoom = 100
.StyleAreaWidth = CentimetersToPoints(3)
End With
End Sub
Macro #4 - Relative change of zoom
The macro below is an example of how you can change the zoom percentage relatively compared to the current zoom. In this example, the zoom percentage is increased by 10%. For example, if the zoom percentage is 75%, it will be changed to 85%. You can run the macro repeatedly until the zoom percentage is as desired.
The macro code:
Sub IncreaseZoomBy10Percent()
With ActiveDocument.ActiveWindow.View.Zoom
.Percentage = .Percentage + 10
End With
End Sub
Related information
See About VBA Macros and Code Snippets and How to Install a Macro for misc. information that may help you in your work with macros and for information about how to install macros.
For information about how Word document windows behave by default in Word 2010 and earlier versions, see my article How To Open Word Documents With A Specific Zoom And View,
You will find information about conflict view in this article: Conflict resolution mode in Word.