Microsoft KB Archive/212713

= WD2000: Run-Time Error 5868 Using VBA Macro to Resize Document Window =

Article ID: 212713

Article Last Modified on 8/10/2007

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q212713





SYMPTOMS
When you attempt to resize or reposition a document window using one of the Microsoft Visual Basic for Applications document window properties (Width, Height, Left, or Top), the following error message may appear:

Run-time error '5868': Window is maximized.



CAUSE
This error occurs because the document window is in a maximized window state. You cannot resize a window while it is in a maximized state.



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To work around this problem, you can set the active window state to "Normal" before you attempt to resize the window. To do this, add the .WindowState property to the macro before you define the Width, Height, Left, and Top properties: Sub ResizeDocumentWindow ' If there are no open Windows then exit this routine. If Windows.Count = 0 Then Exit Sub ' The With statement sets the Window State to Normal and sets ' the Width, Height, Left, and Top properties. With ActiveWindow ' Set the window state to Normal. .WindowState = wdWindowStateNormal ' Resize the window. .Width = 400 .Height = 200 .Left = 10 .Top = 32 End With End Sub



MORE INFORMATION
For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

212536 OFF2000: How to Run Sample Code from Knowledge Base Articles

