Close all Documents Example (VBA)
This example shows how to close all documents in a SolidWorks session.
'---------------------------------------
'
' Preconditions: At least one model document is open in
' the
SolidWorks session.
' Postconditions: All documents meeting the specified
criteria are closed.
'
'----------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim boolstatus As Boolean
Sub main()
Set
swApp = Application.SldWorks
'
If IncludeUnsaved is False, then all documents, excluding any dirty documents,
are closed
boolstatus
= swApp.CloseAllDocuments(False)
Debug.Print
boolstatus
'
If IncludeUnsaved is True, then all documents, including any dirty documents,
are closed
'boolstatus
= swApp.CloseAllDocuments(True)
'Debug.Print
boolstatus
End Sub