Microsoft KB Archive/269570

= WD2000: Windows Property Causes Error 5941 When You Make Document Visible =

Article ID: 269570

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q269570



SYMPTOMS
When you create a document by using a Visual Basic for Applications macro and then later want to make the document visible, as in this sample macro, Sub OpenHiddenDocs

Dim oDoc As Document

Set oDoc = Documents.Add(Visible:=False) oDoc.Windows(1).Visible = True

End Sub Microsoft Word displays the following error message:

Run-time error '5941':

The requested member of the collection does not exist.



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.

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

To prevent this problem, use the ActiveWindow property, as in the following sample macro: Sub OpenHiddenDocs

Dim oDoc As Document

Set oDoc = Documents.Add(Visible:=False) oDoc.ActiveWindow.Visible = True

End Sub For more information about the ActiveWindow property, from the Visual Basic Editor, click Contents and Index on the Help menu, click the Index tab in Microsoft Visual Basic Help, type the following text

activewindow

and then double-click the selected text to go to the &quot;ActiveWindow Property&quot; topic. If you are unable to find the information you need, ask the Office Assistant.



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

Additional query words: vba Run-time run time error 5941

Keywords: kbbug kbdtacode kbmacroexample kbpending KB269570

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.