Option Compare Database Option Private Module Option Explicit Dim ignoreref As String ' for tests Public Sub set_ignoreref(str) ignoreref = str End Sub ' Import References from a CSV Public Function ImportReferences() As Boolean Dim file_path As String Dim count, total As Integer file_path = joinpaths(source_dir(), "references.csv") logger "ImportReferences", "INFO", "Import References" logger "ImportReferences", "DEBUG", "> import from: " & file_path Dim fso As Object Dim InFile As Object Dim Line As String Dim item() As String Dim GUID As String Dim Major As Long Dim Minor As Long Dim filename As String Dim refName As String filename = dir$(file_path) If Len(filename) = 0 Then logger "ImportReferences", "INFO", "> No references to import" End If Set fso = CreateObject("Scripting.FileSystemObject") Set InFile = fso.OpenTextFile(file_path, iomode:=ForReading, Create:=False, Format:=TristateFalse) On Error GoTo failed_guid Do Until InFile.AtEndOfStream Line = InFile.readline item = Split(Line, ",") If UBound(item) = 2 Then 'a ref with a guid GUID = Trim$(item(0)) Major = CLng(item(1)) Minor = CLng(item(2)) Application.References.AddFromGuid GUID, Major, Minor count = count + 1 Else refName = Trim$(item(0)) Application.References.AddFromFile refName count = count + 1 End If go_on: Loop On Error GoTo 0 InFile.Close Set InFile = Nothing Set fso = Nothing logger "ImportReferences", "INFO", count & " imported from " & filename Exit Function failed_guid: If err.Number = 32813 Then 'The reference is already present in the access project - so we can ignore the error Resume Next Else logger "ImportReferences", "ERROR", "Failed to register " & GUID Resume go_on End If End Function ' Export References to a CSV Public Sub ExportReferences() Dim filePath As String Dim fso As Object Dim OutFile As Object Dim Line As String Dim ref As Reference Dim count As Integer Dim item As Variant count = 0 logger "ExportReferences", "INFO", "Export references" filePath = joinpaths(source_dir(), "references.csv") logger "ExportReferences", "DEBUG", "> export to: " & filePath Set fso = CreateObject("Scripting.FileSystemObject") Set OutFile = fso.CreateTextFile(filePath, overwrite:=True, unicode:=False) For Each ref In Application.References For Each item In Split(ignoreref, ",") If ref.name = CStr(item) Then GoTo go_on Next item If ref.GUID <> vbNullString Then ' references of types mdb,accdb,mde etc don't have a GUID If Not ref.BuiltIn Then Line = ref.GUID & "," & CStr(ref.Major) & "," & CStr(ref.Minor) OutFile.WriteLine Line logger "ExportReferences", "DEBUG", "> Reference " & Line & " exported" count = count + 1 End If Else Line = ref.FullPath OutFile.WriteLine Line logger "ExportReferences", "DEBUG", "> Reference " & Line & " exported" count = count + 1 End If go_on: Next OutFile.Close logger "ExportReferences", "INFO", count & " references exported" End Sub