You receive run-time error 4248, 4605 or 5941 when you try to change properties on an unopened document in Word
This command is not available because no document is open.
This method or property is not available because a document window is not active.
The requested member of the collection does not exist.
Note These error messages may also appear if you open the document with the Visible property set to False.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified Partners - https://partner.microsoft.com/global/30000104
Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
For additional information about how to use the sample code that is included in this article, click the following article number to view the article in the Microsoft Knowledge Base:
Sub ChangeDocProperties() On Error GoTo ErrHandler ActiveDocument.BuiltInDocumentProperties("Title") = "My Title" Exit Sub ErrHandler: If Err <> 0 Then' ' Display an error message.' MsgBox Err.Description' ' Clear the error.' Err.Clear Resume Next End If End Sub
- Trap the error, in case there are no documents open.
- In the error trap, create a new document.
- Resume execution at the line that caused the error.
Sub ChangeDocProperties() On Error GoTo ErrHandler ActiveDocument.BuiltInDocumentProperties("Title") = "My Title" Exit Sub ErrHandler: If Err <> 0 Then' ' Add a document.' Documents.Add' ' Clear the error.' Err.Clear'' Run the code that caused the error.' Resume End If End Sub
Article ID: 813983 - Last Review: 01/29/2007 19:48:33 - Revision: 5.3
- kberrmsg kbprb KB813983