WD2000: Run-Time Error 5868 Using VBA Macro to Resize Document Window (212713)
The information in this article applies to:
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.
WORKAROUNDMicrosoft 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
For information about how to do this in earlier versions of Word, click the article number below to view the article in the Microsoft Knowledge Base:
88499 WinWord Err Msg: 'WordBasic Err=509,' with DocSize or DocMove
REFERENCES
For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:
226118 OFF2000: Programming Resources for Visual Basic for Applications
Modification Type: | Major | Last Reviewed: | 6/17/2005 |
---|
Keywords: | kbdtacode kberrmsg kbnofix kbprb KB212713 |
---|
|