Back to Samples Menu

VBA Samples

Microsoft Word 97 and up

Force Your Preferred View

When you open Word documents, particularly from other people, they may open in Normal view or some other view that you don't prefer. This code opens ALL new and previously created files in Print Layout View (in '97, this is called Page Layout view).

Copy all three pieces of the code below. Paste it into the ThisDocument of your Normal.Dot file.

Private Sub Document_New()
  SetView wdPrintView
End Sub

Private Sub Document_Open()
  SetView wdPrintView
End Sub

Private Sub SetView(ByVal iView As Integer)
  With ActiveDocument.ActiveWindow
    If .View.SplitSpecial = wdPaneNone Then
        .ActivePane.View.Type = iView
    Else
        .View.Type = iView
    End If
  End With
End Sub

This graphic depicts the VB Editor in Word 2000. To open the VB Editor, hit Alt+F11. To get to the appropriate place to paste your code, double-click ThisDocument under Normal. Paste your code into the right-hand window. Save by clicking on the diskette icon. Close the VB Editor window. Close Word. From now on, all your documents will open in Print Layout View.

If you prefer Normal view, then simply change the red text in both places of the code to wdNormalView.