Closes the specified drawing, or all open drawings.
Supported platforms: Windows only
VBA:
object.Close [SaveChanges] [, FileName]
The objects this method applies to.
Access: Input-only; optional
Type: Variant
Specifies if the drawing is to be saved or not. (Not applicable when called from Documents collection.)
Access: Input-only; optional
Type: String
The name to assign to the drawing. If no name is provided when saving a drawing for the first time, the drawing will be saved using the VBA project information: ThisDrawing.Path\ThisDrawing.Name. (Not applicable when called from Documents collection.)
No return value.
If there are no changes to the drawing, SaveChanges and FileName are ignored. If there are changes to the drawing, SaveChanges specifies whether changes should be saved. The default value for the SaveChanges parameter is True.
Calling this method from the Documents collection in MDI mode will close all open drawings. To close a single drawing, call this method from the drawing to be closed.
You cannot close a drawing from inside an event handler for that drawing.
VBA:
Sub Example_Close() ' This example cycles through the documents collection ' and closes all open drawings using the Close method. Dim DOC As AcadDocument ' If there are no open documents, then exit If Documents.count = 0 Then MsgBox "There are no open documents!" Exit Sub End If ' Close all open documents For Each DOC In Documents If MsgBox("Do you wish to close the document: " & DOC.WindowTitle, vbYesNo & vbQuestion) = vbYes Then If DOC.FullName <> "" Then DOC.Close Else MsgBox DOC.name & " has not been saved yet, so it will not be closed." End If End If Next End Sub
Visual LISP:
(vl-load-com) (defun c:Example_Close() ;; This example cycles through the documents collection ;; and closes all open drawings using the Close method ;; except the current drawing. (setq acadObj (vlax-get-acad-object)) (setq curDoc (vla-get-ActiveDocument acadObj)) (setq docs (vla-get-Documents acadObj)) ;; Close all open documents and discard changes, except for the current drawing (vlax-for doc docs (if (/= (vla-get-Name doc) (vla-get-Name curDoc)) (progn (alert (strcat "Closing " (vla-get-Name doc) " file.")) (vla-Close doc :vlax-false) ) ) ) )