AutoCAD always starts up with a new or existing document open. It is possible, however, to close all documents during the current session.
If you close all the documents in the AutoCAD user interface, you will notice a few changes to the application window. The available menus are reduced to simply the File, View, Window, and Help menus. These menus also have reduced available options on them. You will also notice that there is no command line.
Similarly, the ActiveX interface only allows the following actions when no documents are open:
- You can open a document.
- You can create a new document.
- You can import a document.
- You can exit out of AutoCAD.
These actions are all available from the Documents collection. The methods and properties of the Documents collection, in addition to a limited set of methods and properties of the Application object, are the only valid interface available when there are no documents open. If you perform any other action, such as attempting to access user options, your actions will result in an error.
Use the Count property on the Documents collection to determine if AutoCAD is in a zero document state. If Documents.Count = 0, then AutoCAD is in a zero document state. If Documents.Count > 0, then there is at least one drawing open.
It is also important to note that in VBA the ThisDrawing object is not defined when AutoCAD is in a zero document state. This makes sense since ThisDrawing normally refers to the active drawing and in the zero document state there are no drawings open. Attempting to execute a macro that uses ThisDrawing will result in a runtime error. To avoid the error, use the VBA GetObject function, and specify the AutoCAD version, to obtain a connection to AutoCAD when there are no documents open.