Closing all documents that have not been edited

Closing all documents that have not been edited

Hubert_Los
Advocate Advocate
253 Views
1 Reply
Message 1 of 2

Closing all documents that have not been edited

Hubert_Los
Advocate
Advocate

Hello,

I would like close all documents that have not been edited.

Can I check if a document was edited in the current session?
 

Public Sub CloseAllOpenDocuments()


Set oApp = ThisApplication
Dim oDoc As Document


For Each oDoc In ThisApplication.Documents.VisibleDocuments
    If Not oDoc.ActivatedObject Is Nothing Then
        If .... Then ?
            Call oDoc.Close
        End If
    End If
    
Next

End Sub

 

0 Likes
Accepted solutions (1)
254 Views
1 Reply
Reply (1)
Message 2 of 2

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

Hi @Hubert_Los . You can use the Dirty function to understand if there have been changes in the documents, if not the document is closed.

 

Public Sub CloseAllOpenDocuments()

	Set oApp = ThisApplication
	Dim oDoc As Document
	
	
	For Each oDoc In oApp.Documents.VisibleDocuments
	    If Not oDoc.ActivatedObject Is Nothing Then
	        If Not oDoc.Dirty Then Call oDoc.Close
	    End If    
	Next

End Sub

 

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes