WD: Macro to Cascade Open Document Windows

Last reviewed: July 30, 1997
Article ID: Q90894
The information in this article applies to:
  • Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a

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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.