Option Compare Database Option Explicit Public Sub ImportAll() Dim db As DAO.Database Dim FSO As Object logger "ImportAll", "INFO", "Begin 'Import all sources'" Set FSO = CreateObject("Scripting.FileSystemObject") Set db = CurrentDb If Not FSO.FolderExists(source_dir()) Then logger "ImportAll", "CRITICAL", "No source found at:" & source_dir End If ' close any opened form or report, except OpenAccess's form Call CloseFormsReports ' import database properties Call ImportProperties(CurrentDb, joinpaths(source_dir, "database.properties")) Call ImportAllQueries Call ImportAllTblDefs Call ImportAllTableDatas Call ImportAllDataMacros Call ImportAllDocs(acForm) Call ImportAllDocs(acReport) Call ImportAllPrintVars Call ImportAllDocs(acMacro) Call ImportReferences Call ImportAllDocs(acModule) Call ImportAllRelations SaveProject logger "ImportAll", "INFO", "Import done" End Sub Public Sub ImportAllQueries() Dim dirpath, obj_name As String Dim filename As Variant Dim count, total As Integer dirpath = joinpaths(source_dir(), "queries\") logger "ImportAllQueries", "INFO", "Import queries" logger "ImportAllQueries", "DEBUG", "> import from: " & dirpath count = 0 total = 0 Dim to_import As String to_import = list_files_in(dirpath, "*.bas") total = UBound(Split(to_import, "|")) + 1 If Len(to_import) > 0 Then For Each filename In Split(to_import, "|") obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1) obj_name = to_accessname(obj_name) ImportDocument acQuery, obj_name, joinpaths(dirpath, filename) count = count + 1 Call SysCmd(acSysCmdSetStatus, "Import query: " & count & " on " & total) filename = dir$() Next filename logger "ImportAllQueries", "INFO", "> " & count & " queries imported" Else logger "ImportAllQueries", "INFO", "> No query to import" End If Call SysCmd(acSysCmdClearStatus) End Sub Public Sub ImportAllTblDefs() Dim dirpath, obj_name As String Dim filename As Variant Dim count, total As Integer dirpath = joinpaths(source_dir(), "tbldefs\") logger "ImportAllTblDefs", "INFO", "Import table defs" logger "ImportAllTblDefs", "DEBUG", "> import from: " & dirpath count = 0 total = 0 Dim to_import As String to_import = list_files_in(dirpath, "*.sql") total = UBound(Split(to_import, "|")) + 1 If Len(to_import) > 0 Then For Each filename In Split(to_import, "|") obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1) obj_name = to_accessname(obj_name) ImportTableDef CStr(obj_name), dirpath count = count + 1 Call SysCmd(acSysCmdSetStatus, "Import tabledef: " & count & " on " & total) Next filename logger "ImportAllTblDefs", "INFO", "> " & count & " TblDefs imported" Else logger "ImportAllTblDefs", "INFO", "> No tabledef to import" End If Call SysCmd(acSysCmdClearStatus) End Sub Public Sub ImportAllLinkedTables() Dim dirpath, obj_name As String Dim filename As Variant Dim count, total As Integer dirpath = joinpaths(source_dir(), "tbldef\") logger "ImportAllLinkedTables", "INFO", "Import linked tables" logger "ImportAllLinkedTables", "DEBUG", "> import from: " & dirpath count = 0 total = 0 Dim to_import As String to_import = list_files_in(dirpath, "*.LNKD") total = UBound(Split(to_import, "|")) + 1 If Len(to_import) > 0 Then For Each filename In Split(to_import, "|") obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1) obj_name = to_accessname(obj_name) ImportLinkedTable CStr(obj_name), dirpath count = count + 1 Call SysCmd(acSysCmdSetStatus, "Import linked table: " & count & " on " & total) Next filename logger "ImportAllLinkedTables", "INFO", "> " & count & " Linked TblDefs imported" Else logger "ImportAllLinkedTables", "INFO", "> No linked table to import" End If Call SysCmd(acSysCmdClearStatus) End Sub Public Sub ImportAllTableDatas() Dim dirpath, obj_name As String Dim filename As Variant Dim count, total As Integer dirpath = joinpaths(source_dir(), "tables\") logger "ImportAllTableDatas", "INFO", "Import table datas" logger "ImportAllTableDatas", "DEBUG", "> import from: " & dirpath count = 0 total = 0 Dim to_import As String to_import = list_files_in(dirpath, "*.txt") total = UBound(Split(to_import, "|")) + 1 If Len(to_import) > 0 Then For Each filename In Split(to_import, "|") obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1) obj_name = to_accessname(obj_name) ImportTableData CStr(obj_name), dirpath count = count + 1 Call SysCmd(acSysCmdSetStatus, "Import table data: " & count & " on " & total) Next filename logger "ImportAllTableDatas", "INFO", "> " & count & " table's data imported" Else logger "ImportAllTableDatas", "INFO", "> " & count & " table's data imported" End If Call SysCmd(acSysCmdClearStatus) End Sub Public Sub ImportAllDataMacros() Dim dirpath, obj_name As String Dim filename As Variant Dim count, total As Integer dirpath = joinpaths(source_dir(), "tbldef\") logger "ImportAllDataMacros", "INFO", "Import DataMacros" logger "ImportAllDataMacros", "DEBUG", "> import from: " & dirpath count = 0 total = 0 Dim to_import As String to_import = list_files_in(dirpath, "*.xml") total = UBound(Split(to_import, "|")) + 1 If Len(to_import) > 0 Then For Each filename In Split(to_import, "|") obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1) obj_name = to_accessname(obj_name) ImportDataMacros obj_name, dirpath Call SysCmd(acSysCmdSetStatus, "Import DataMacro: " & count & " on " & total) count = count + 1 Next filename logger "ImportAllDataMacros", "INFO", "> " & count & " DataMacros imported" Else logger "ImportAllDataMacros", "INFO", "> " & count & " DataMacros imported" End If Call SysCmd(acSysCmdClearStatus) End Sub Public Sub ImportAllDocs(ByVal acType As Integer, Optional ByVal encoding = "utf-8") Dim doc_label As String Dim dirpath, obj_name As String Dim filename As Variant Dim count, total As Integer 'get the document's container's name from it's type doc_label = get_container_name(acType) If Len(doc_label) = 0 Then logger "ImportAllDocs", "CRITICAL", "acType " & acType & " is not recognized!" Exit Sub End If dirpath = joinpaths(source_dir(), doc_label & "\") logger "ImportAllDocs", "INFO", "# Import " & doc_label logger "ImportAllDocs", "DEBUG", "> import from: " & dirpath count = 0 total = 0 Dim to_import As String to_import = list_files_in(dirpath, "*.bas") total = UBound(Split(to_import, "|")) + 1 If Len(to_import) > 0 Then For Each filename In Split(to_import, "|") obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1) obj_name = to_accessname(obj_name) If IsNotVCS(obj_name) Then ImportDocument acType, obj_name, joinpaths(dirpath, filename) Else logger "ImportAllDocs", "WARNING", "Module " & obj_name & " could not be updated while running. Ensure latest version is included!" End If count = count + 1 Call SysCmd(acSysCmdSetStatus, "Import " & doc_label & ": " & count & " on " & total) Next filename logger "ImportAllDocs", "INFO", "> " & count & " " & doc_label & " imported" Else logger "ImportAllDocs", "INFO", "> No " & doc_label & " to import" End If Call SysCmd(acSysCmdClearStatus) End Sub Public Sub ImportAllPrintVars() Dim dirpath, obj_name As String Dim filename As Variant Dim count, total As Integer dirpath = joinpaths(source_dir(), "reports\") logger "ImportAllPrintVars", "INFO", "Import Print Vars" logger "ImportAllPrintVars", "DEBUG", "> import from: " & dirpath count = 0 total = 0 Dim to_import As String to_import = list_files_in(dirpath, "*.pv") total = UBound(Split(to_import, "|")) + 1 If Len(to_import) > 0 Then For Each filename In Split(to_import, "|") obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1) obj_name = to_accessname(obj_name) ImportPrintVars obj_name, joinpaths(dirpath, filename) count = count + 1 Call SysCmd(acSysCmdSetStatus, "Import Print Vars: " & count & " on " & total) Next filename logger "ImportAllPrintVars", "INFO", "> " & count & " Print Vars imported" Else logger "ImportAllPrintVars", "INFO", "> No Print Vars to import" End If Call SysCmd(acSysCmdClearStatus) End Sub Public Sub ImportAllRelations() Dim dirpath As String Dim filename As Variant Dim count, total As Integer dirpath = joinpaths(source_dir(), "relations\") logger "ImportAllRelations", "INFO", "Import Relations" logger "ImportAllRelations", "DEBUG", "> import from: " & dirpath count = 0 total = 0 Dim to_import As String to_import = list_files_in(dirpath, "*.txt") total = UBound(Split(to_import, "|")) + 1 If Len(to_import) > 0 Then For Each filename In Split(to_import, "|") ImportRelation joinpaths(dirpath, filename) count = count + 1 Call SysCmd(acSysCmdSetStatus, "Import relation: " & count & " on " & total) Next filename logger "ImportAllRelations", "INFO", "> " & count & " Relations imported" Else logger "ImportAllRelations", "INFO", "> No relation to import" End If Call SysCmd(acSysCmdClearStatus) End Sub