Microsoft KB Archive/210253

= WD2000: WindowState Property Returns 1 (Maximized ) Instead of (2) Minimized As Expected =

Article ID: 210253

Article Last Modified on 9/12/2006

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q210253



SYMPTOMS
When you create the following Microsoft Visual Basic macro for Microsoft Word 2000 Sub newdoc Application.NewWindow ActiveWindow.WindowState = wdWindowStateMinimize MsgBox ActiveWindow.WindowState End Sub and you then run the macro to create a new document window and report the state of the window, the message box indicates a maximized state (1) instead of the actual state of the new window. The new window is minimized, therefore the message box should report a minimized state (2).

In Word 97, the same macro reports a normal state (0).



CAUSE
This behavior occurs when you run the macro from a maximized Word document. Microsoft Windows returns focus to the last active window when you minimize another window. Because the last active window is maximized, the message box correctly returns a windows state of 1 (maximized).

Word 97 changes the active window to a normal (restored) state, therefore in Word 97, the message box returns a window state of 0 (normal).

When you run the macro from a restored Word 2000 document, the message box returns a window state of 0.



RESOLUTION
To resolve this issue and create a macro that returns the correct window state of the new document, follow these steps:  Start Word 2000. Press ALT+F11 to start the Visual Basic Editor. On the Insert menu, click Module.  In the module sheet, type the following code: Sub newdoc Set myWindow = Application.NewWindow myWindow.WindowState = wdWindowStateMinimize MsgBox myWindow.WindowState End Sub  Press ALT+F11 to return to Word. On the Tools menu, point to Macro, and then click Macros.</li> Select newdoc, and then click Run. You create a new, minimized document, and the message box returns a windows state of 2 (minimized).</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

<div class="references_section">