WD: Macro to Cascade Open Document Windows

ID: Q90894

The information in this article applies to:

SUMMARY

Microsoft Word does not contain a command to cascade all open document windows. You can add this functionality using a WordBasic macro. The following macro examples cascade all open Word document windows. After you create this macro, you can assign it to the Windows menu for easy access.

MORE INFORMATION

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

   Sub MAIN
      'Report current zoom factor, place in "Zoom"
      Zoom = SelInfo(19)
      On Error Resume Next
      'Determine whether Word is in Outline view
      Outview = ViewOutline()
      'Set ViewZoom to 100%
      ViewZoom100
      'Maximize document window
      If DocMaximize() Then DocMaximize
      'Count number of open windows
      NumWindows = CountWindows() - 1
      'Vertical overlap is 14
      Vlap = 14
      'Horizontal overlap is 7
      Hlap = 7
      'Calculate width of window in points
      Width = Val(AppInfo$(6)) - NumWindows * HLap
      'Calculate height of windows in points
      Height = Val(AppInfo$(7)) - NumWindows * VLap
      ' The following loop calculates window size and
      ' moves them into position.
      For Cascade = 1 To NumWindows + 1
         NextWindow
         DocMove NewWidth, NewHeight
         DocSize Width, Height
         NewWidth = NewWidth + HLap
         NewHeight = NewHeight + VLap
      Next Cascade
      'Return to former zoom factor
      ViewZoom .ZoomPercent = Zoom
      'If formerly in outline view, then return to outline view.
      If Outview Then ViewOutline
   End Sub

Word for the Macintosh

   Sub MAIN
      'Report current zoom factor, place in "Zoom"
      Zoom = SelInfo(19)
      On Error Resume Next
      'Determine whether Word is in Outline view
      OutlineX = ViewOutline()
      'Set ViewZoom to 100%
      ViewZoom100
      'Maximize document window
      If DocMaximize() Then DocMaximize
      'Count number of open windows
      NumWindows = CountWindows() - 1
      'Vertical overlap is 14
      Vlap = 14
      'Horizontal overlap is 7
      Hlap = 7
      'Calculate width of window in points.
      Width = Val(AppInfo$(6)) - NumWindows * HLap
      'Calculate height of windows in points.
      Height = Val(AppInfo$(7)) - NumWindows * VLap
      ' The following loop calculates window size and
      ' moves them into position.
      For Cascade = 1 To NumWindows + 1
         NextWindow
         DocMove NewWidth, NewHeight
         DocSize Width, Height
         NewWidth = NewWidth + HLap
         NewHeight = NewHeight + VLap
      Next Cascade
      'Return to former zoom factor
      ViewZoom .ZoomPercent = Zoom
      'If formerly in outline view, then return to outline view.
      If OutlineX Then ViewOutline
   End Sub

REFERENCES

"Microsoft Word for Windows User's Guide," version 2.0, pages 784-786

Additional query words: cascaded overlap overlapped overlapping cascading Version : 2.x 6.0 6.0a 6.0c 7.0 7.0a

Last Reviewed: July 30, 1997