Close method example

The following example demonstrates how to use the Close method.

Sub Close_Example()
' This example cycles through the documents collection
' and closes all open drawings using the Close method.
    ' If there are no open documents, then exit
    If ThisDrawing.Application.Documents.Count = 0 Then
        MsgBox "There are no open documents!"
        Exit Sub
    End If
    ' Close all open documents
    Dim thisDoc As AcadDocument
    For Each thisDoc In ThisDrawing.Application.Documents
        If MsgBox("Do you wish to close the document: " & thisDoc.Name, vbYesNo) = vbYes Then
            If thisDoc.FullName <> "" Then
                thisDoc.Close False
                MsgBox thisDoc.Name & " has not been saved yet, so it will not be closed."
            End If
        End If
End Sub

© Bricsys NV. All rights reserved.