Article ID: 209160 - Last Review: June 17, 2005 - Revision: 2.0 WD2000: Error Message: "Run-time error '4248'; 'This command is not available because no document is open.'"This article was previously published under Q209160 SYMPTOMS
If you attempt to use Visual Basic for Applications to change the
properties of a document, you may receive one of the following error
messages:
Run-time error '4248': This command is not available because no document is open.
-or-
Run-time error '4605': Bad File Name
-or-
Run-time error '5941': The requested member of the collection does not exist. CAUSE
One of these error messages may appear when no documents are currently open or the document you are referencing is not open. Word can only change the properties of an open (or visible) document. NOTE: These error messages may also appear if you have opened the document with the Visible property set to False. For additional information about treating hidden documents in the document collection, please see the following article in the Microsoft Knowledge Base: 220504
(http://support.microsoft.com/kb/220504/EN-US/
)
WD2000: Documents/Windows Collection Fails to Include Hidden Documents
NOTE: In earlier versions of Word, no error message is displayed, and no document properties are changed.
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.
The following sample Visual Basic for Applications macros demonstrate how to change the value of the Title field in the Properties dialog box. This following sample includes code to trap the error, in case there are no documents open, and display a message: The following sample includes code to
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
(http://support.microsoft.com/kb/212536/EN-US/
)
OFF2000: How to Run Sample Code from Knowledge Base Articles
REFERENCES
For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base: 226118
(http://support.microsoft.com/kb/226118/EN-US/
)
OFF2000: Programming Resources for Visual Basic for Applications
| Article Translations
|
Back to the top
