Word

Default Open View

Ease of Use

Easy

Version tested with

2000 

Submitted by:

Anne Troy

Description:

Sets a desired view on open of documents, regardless of the view in which they were saved. 

Discussion:

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). Document_Open in the normal.dot template is an event that occurs any time you open any document. Document_New in the normal.dot template is an event that occurs whenever you create a new document. Hence, this code does not open the Word application in the view that is coded, but will open documents and create new documents in the view that is coded. 

Code:

instructions for use

			

'In the two SetView commands, change "wdPrintView" to any of the following views desired: 'wdNormalView, wdOutlineView, wdPrintPreview Private Sub Document_New() Call SetView (wdPrintView) End Sub Private Sub Document_Open() Call SetView (wdPrintView) End Sub Private Sub SetView(ByVal iView As Integer) With ActiveDocument.ActiveWindow If .View.SplitSpecial = wdPaneNone Then .ActivePane.View.Type = iView .ActivePane.View.Zoom.PageFit = wdPageFitBestFit Else .View.Type = iView .View.Zoom.PageFit = wdPageFitBestFit End If End With End Sub

How to use:

  1. Copy the code above.
  2. Open Word.
  3. Hit Alt+F11 to open the Visual Basic Editor (VBE).
  4. Double-click ThisDocument under Normal on the left-hand side.
  5. Paste the code into the right-hand code window.
  6. Hit the save diskette button.
  7. Close the VBE.
 

Test the code:

  1. Open any document, and it will be opened in your desired layout.
 

Sample File:

No Attachment 

Approved by Anne Troy


This entry has been viewed 76 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2014 VBA Express