指定された図面や開いているすべての図面を閉じます。
サポートされているプラットフォーム: Windows のみ
VBA:
object.Close [SaveChanges] [, FileName]
このメソッドが適用されるオブジェクト。
アクセス: 入力のみ(オプション)
タイプ: バリアント型
図面を保存するかどうかを指定します。(Documents コレクションから呼び出された場合は適用できません)
アクセス: 入力のみ(オプション)
タイプ: 文字列
図面に割り当てる名前。初めて図面を保存する際に名前を指定しないと、図面は VBA プロジェクト情報(ThisDrawing.Path¥ThisDrawing.Name)を使用して保存されます。(Documents コレクションから呼び出された場合は適用できません)
戻り値はありません。
図面に変更がない場合は、SaveChanges および FileName は無視されます。図面に変更がある場合は、SaveChanges は変更を保存する必要があるかどうかを指定します。SaveChanges パラメータの既定値は True です。
MDI モードでDocuments コレクションからこのメソッドを呼び出すと、開いている図面がすべて閉じてしまいます。単一図面を閉じるには、閉じる図面からこのメソッドを呼び出します。
図面をそのイベント ハンドラ内部から閉じることはできません。
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)
	    )
        )
    )
)