Class Windows (Word VBA)

A collection of Window objects that represent all the available windows. The Windows collection for the Application object contains all the windows in the application, whereas the Windows collection for the Document object contains only the windows that display the specified document. To use a Windows class variable it first needs to be instantiated, for example


Dim wnds as Windows
Set wnds = Windows

For Each

Here is an example of processing the Windows items in a collection.


Dim wnd As Window
For Each wnd In Windows
	
Next wnd

Add

Returns a Window object that represents a new window of a document.

A colon (:) and a number appear in the window caption when more than one window is open for the document.

Add (Window)

Window: The Window object you want to open another window for. If this argument is omitted, a new window is opened for the active document.


Windows.Add

Arrange

Arranges all open document windows in the application workspace.

Because Microsoft Word uses a Single Document Interface (SDI), this method no longer has any effect.

Arrange (ArrangeStyle)

ArrangeStyle: The window arrangement. Can be either of the following WdArrangeStyle constants: wdIcons or wdTiled.


Windows.Arrange ArrangeStyle:=wdTiled

BreakSideBySide

Ends side by side mode if two windows are in side by side mode. Returns a Boolean that represents whether the method was successful.


ActiveDocument.Windows.BreakSideBySide

CompareSideBySideWith

Opens two windows in side by side mode. Returns a Boolean.

You cannot use the CompareSideBySideWith method with the Application object or the ActiveDocument property.

CompareSideBySideWith (Document)

Document: The document to view in side by side windows.


Dim objDoc1 As Word.Document 
Dim objDoc2 As Word.Document 
 
Set objDoc1 = Documents.Add 
Set objDoc2 = Documents.Add 
 
objDoc2.Activate 
objDoc2.Windows.CompareSideBySideWith objDoc1 
Windows.ResetPositionsSideBySide

Count

Returns a Long that represents the number of windows in the collection.


Dim lngCount As Long
lngCount = Windows.Count

Item

Returns an individual Window object in a collection.

Item (Index)

Index: The individual object to be returned. Can be a Long indicating the ordinal position or a String representing the name of the individual object.


Dim wnd As Window
Set wnd = Windows(Index:=1)

ResetPositionsSideBySide

Resets two document windows that are in the Compare side by side with view mode.

This method corresponds to the Reset Window Position button on the Compare Side by Side toolbar. Use the ResetPositionsSideBySide method to reset the display of two documents. For example, if a user minimizes or maximizes one of the two document windows being compared, the ResetPositionsSideBySide method resets the display so that the two windows are displayed side by side again.


Windows.ResetPositionsSideBySide

SyncScrollingSideBySide


Windows.SyncScrollingSideBySide = True