Dear Vladimir Ananyev,
Thank your for your contribution in this.
For anyone who can use this piece of code:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Public Sub Open_save_AllReferencedDocs_Dirty() ' Get the Documents collection object.
Dim i As Integer
Dim oDoc As AssemblyDocument 'use the object "Documents" if collect all documents in memory
Set oDoc = ThisApplication.ActiveDocument 'use the object "ThisApplication.Documents" for collect all documents in memory
'Log all filenames from Documents in memory to a specific file
'Give the flag dirty=true when the document was edited.
'If a logfile exist delete it, if not step in to the next line
On Error Resume Next
Kill "D:\\temp\\List AllReferencedDocs Dirty.txt" 'Delete the file
Open "D:\\temp\\List AllReferencedDocs Dirty.txt" For Output As #1 'create and open file
Print #1, Tab(10); "Document Name"; Tab(120); "File Dirty"; vbNewLine 'print a header to the txt file
ThisApplication.SilentOperation = True 'Causes all dialogs to be suppressed and take the default behavior
' Iterate through the contents of the Documents collection.
For i = 1 To oDoc.AllReferencedDocuments.Count 'use object+method "oDoc.Count" for iterate through the all docs in memory collection
' Get a specific item from the Documents collection.
Dim invDoc As Document
Set invDoc = oDoc.AllReferencedDocuments.Item(i) 'use the object+method "oDoc.Item(i)" to get all docs in memory
'Display the full filename of the document in the Immediate window.
Debug.Print invDoc.FullFileName 'only necessarily when debug the code to see what files are in collection
'place filename in open txt document
Print #1, invDoc.FullFileName; Tab(120); invDoc.Dirty
'check if the file is dirty, then open and save it (the file is edited in this session )
If invDoc.Dirty = True Then 'check if the file is dirty, true means file is dirty
ThisApplication.Documents.Open (invDoc.FullFileName) 'Open the specific document
invDoc.Save2 (False) 'Save document without dependents, "Save2( [SaveDependents] As Boolean, [DocumentsToSave] As Variant )"
invDoc.Close 'close the file
End If
Next
ThisApplication.SilentOperation = False
MsgBox ("Completed, see Logfile D:\\temp\\List AllReferencedDocs Dirty.txt.")
'reset the vba code, otherwise the file in D:\\ will still be in use by the VBa application
End
End Sub
------------------------------------------------------------------------------------------------------------------
I would like to thank everyone who has contributed to this forum. It helped me to get more insight into ilogic and the vba language.
with kind regards,
Jeroen Koning