| Close 方法 (ActiveX) 关闭指定的图形或所有打开的图形。 支持的平台:仅限 Windows 签名VBA: object.Close [SaveChanges] [, FileName] 返回值 (RetVal)无返回值。 言论如果图形没有更改,则忽略。如果图形有更改,请指定是否应保存更改。参数的默认值为 。SaveChangesFileNameSaveChangesSaveChangesTrue 
 在 MDI 模式下从 Documents 集合调用此方法将关闭所有打开的图形。若要关闭单个图形,请从要关闭的图形中调用此方法。 不能从图形的事件处理程序中关闭图形。 
注意:关闭图形会破坏对象。一旦对象被销毁,或者在这种情况下,关闭,就不要尝试引用它。进程内客户端 (VBA 宏) 可能会注意到,在退出子例程之前,对象不会被销毁。但是,根本不建议引用已销毁的对象,即使在进程内代码中也是如此。Document 例子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可视化 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)
	    )
        )
    )
) | 
 |Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
GMT+8, 2025-10-31 06:45
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.