WindowState Property

Microsoft Word Visual Basic

WindowState Property

       

Returns or sets the state of the specified document window or task window. Read/write WdWindowState.

WdWindowState can be one of these WdWindowState constants.
wdWindowStateMaximize
wdWindowStateNormal
wdWindowStateMinimize

expression.WindowState

expression   Required. An expression that returns one of the objects in the Applies To list.

Remarks

The wdWindowStateNormal constant indicates a window that's not maximized or minimized. The state of an inactive window cannot be set. Use the Activate method to activate a window prior to setting the window state.

Example

This example maximizes the active window if it's not maximized or minimized.

If ActiveDocument.ActiveWindow _
    .WindowState = wdWindowStateNormal Then _
    ActiveDocument.ActiveWindow.WindowState = wdWindowStateMaximize

This example minimizes the Microsoft Excel application window.

For Each myTask In Tasks
    If InStr(myTask.Name, "Microsoft Excel") > 0 Then
        myTask.Activate
        myTask.WindowState = wdWindowStateMinimize
    End If
Next myTask