remove echos

This commit is contained in:
Lukas Ziegler 2021-03-08 10:14:24 +01:00
parent 3e787b7fcc
commit 1d866f82df
2 changed files with 27 additions and 27 deletions

View File

@ -68,10 +68,10 @@ Function importModulesTxt(ACCDBFilename, sImportpath)
End If End If
End If End If
Wscript.Echo "starting Access..." 'Wscript.Echo "starting Access..."
Dim oApplication Dim oApplication
Set oApplication = CreateObject("Access.Application") Set oApplication = CreateObject("Access.Application")
Wscript.Echo "Opening " & ACCDBFilename 'Wscript.Echo "Opening " & ACCDBFilename
If (Right(ACCDBFilename, 4) = ".adp") Then If (Right(ACCDBFilename, 4) = ".adp") Then
oApplication.CreateAccessProject ACCDBFilename oApplication.CreateAccessProject ACCDBFilename
Else Else
@ -91,31 +91,31 @@ Function importModulesTxt(ACCDBFilename, sImportpath)
Select Case objecttype Select Case objecttype
Case "form" Case "form"
Wscript.Echo "Importing FORM from file " & myFile.Name 'Wscript.Echo "Importing FORM from file " & myFile.Name
oApplication.LoadFromText acForm, objectname, myFile.Path oApplication.LoadFromText acForm, objectname, myFile.Path
Case "module" Case "module"
Wscript.Echo "Importing MODULE from file " & myFile.Name 'Wscript.Echo "Importing MODULE from file " & myFile.Name
oApplication.LoadFromText acModule, objectname, myFile.Path oApplication.LoadFromText acModule, objectname, myFile.Path
Case "macro" Case "macro"
Wscript.Echo "Importing MACRO from file " & myFile.Name 'Wscript.Echo "Importing MACRO from file " & myFile.Name
oApplication.LoadFromText acMacro, objectname, myFile.Path oApplication.LoadFromText acMacro, objectname, myFile.Path
Case "report" Case "report"
Wscript.Echo "Importing REPORT from file " & myFile.Name ' Wscript.Echo "Importing REPORT from file " & myFile.Name
oApplication.LoadFromText acReport, objectname, myFile.Path oApplication.LoadFromText acReport, objectname, myFile.Path
Case "query" Case "query"
Wscript.Echo "Importing QUERY from file " & myFile.Name 'Wscript.Echo "Importing QUERY from file " & myFile.Name
oApplication.LoadFromText acQuery, objectname, myFile.Path oApplication.LoadFromText acQuery, objectname, myFile.Path
Case "table" Case "table"
Wscript.Echo "Importing TABLE from file " & myFile.Name 'Wscript.Echo "Importing TABLE from file " & myFile.Name
oApplication.ImportXml myFile.Path, acStructureOnly oApplication.ImportXml myFile.Path, acStructureOnly
Case "rel" Case "rel"
Wscript.Echo "Found RELATIONSHIPS file " & myFile.Name & " ... opening, it will be processed after everything else has been imported" 'Wscript.Echo "Found RELATIONSHIPS file " & myFile.Name & " ... opening, it will be processed after everything else has been imported"
relDoc.Load (myFile.Path) relDoc.Load (myFile.Path)
End Select End Select
Next Next
If relDoc.readyState Then If relDoc.readyState Then
Wscript.Echo "Preparing to build table dependencies..." ' Wscript.Echo "Preparing to build table dependencies..."
Dim xmlRel, xmlField, accessRel, relTable, relName, relFTable, relAttr, i Dim xmlRel, xmlField, accessRel, relTable, relName, relFTable, relAttr, i
For Each xmlRel In relDoc.SelectNodes("/Relations/Relation") 'loop through every Relation node inside .xml file For Each xmlRel In relDoc.SelectNodes("/Relations/Relation") 'loop through every Relation node inside .xml file
relName = xmlRel.SelectSingleNode("Name").Text relName = xmlRel.SelectSingleNode("Name").Text
@ -130,17 +130,17 @@ Function importModulesTxt(ACCDBFilename, sImportpath)
oApplication.CurrentDb.TableDefs(relFTable).Indexes.Delete (relName) oApplication.CurrentDb.TableDefs(relFTable).Indexes.Delete (relName)
On Error GoTo 0 On Error GoTo 0
Wscript.Echo "Creating relation " & relName & " between tables " & relTable & " -> " & relFTable 'Wscript.Echo "Creating relation " & relName & " between tables " & relTable & " -> " & relFTable
Set accessRel = oApplication.CurrentDb.CreateRelation(relName, relTable, relFTable, relAttr) 'create the relationship object Set accessRel = oApplication.CurrentDb.CreateRelation(relName, relTable, relFTable, relAttr) 'create the relationship object
For Each xmlField In xmlRel.SelectNodes("Field") 'in case the relationship works with more fields For Each xmlField In xmlRel.SelectNodes("Field") 'in case the relationship works with more fields
accessRel.Fields.Append accessRel.CreateField(xmlField.SelectSingleNode("Name").Text) accessRel.Fields.Append accessRel.CreateField(xmlField.SelectSingleNode("Name").Text)
accessRel.Fields(xmlField.SelectSingleNode("Name").Text).ForeignName = xmlField.SelectSingleNode("ForeignName").Text accessRel.Fields(xmlField.SelectSingleNode("Name").Text).ForeignName = xmlField.SelectSingleNode("ForeignName").Text
Wscript.Echo " Involving fields " & xmlField.SelectSingleNode("Name").Text & " -> " & xmlField.SelectSingleNode("ForeignName").Text 'Wscript.Echo " Involving fields " & xmlField.SelectSingleNode("Name").Text & " -> " & xmlField.SelectSingleNode("ForeignName").Text
Next Next
oApplication.CurrentDb.Relations.Append accessRel 'append the newly created relationship to the database oApplication.CurrentDb.Relations.Append accessRel 'append the newly created relationship to the database
Wscript.Echo " Relationship added" ' Wscript.Echo " Relationship added"
Next Next
End If End If

View File

@ -48,15 +48,15 @@ Function exportModulesTxt(ACCDBFilename, sExportpath)
If (sExportpath = "") Then If (sExportpath = "") Then
sExportpath = myPath & "\Source" sExportpath = myPath & "\Source"
End If End If
'On Error Resume Next On Error Resume Next
fso.DeleteFolder (sExportpath) fso.DeleteFolder (sExportpath)
fso.CreateFolder (sExportpath) fso.CreateFolder (sExportpath)
On Error GoTo 0 On Error GoTo 0
Wscript.Echo "starting Access..." 'Wscript.Echo "starting Access..."
Dim oApplication Dim oApplication
Set oApplication = CreateObject("Access.Application") Set oApplication = CreateObject("Access.Application")
Wscript.Echo "Opening " & ACCDBFilename & " ..." 'Wscript.Echo "Opening " & ACCDBFilename & " ..."
If (Right(ACCDBFilename, 4) = ".adp") Then If (Right(ACCDBFilename, 4) = ".adp") Then
oApplication.OpenAccessProject ACCDBFilename oApplication.OpenAccessProject ACCDBFilename
Else Else
@ -64,33 +64,33 @@ Function exportModulesTxt(ACCDBFilename, sExportpath)
End If End If
oApplication.Visible = False oApplication.Visible = False
Wscript.Echo "exporting..." ' Wscript.Echo "exporting..."
Dim myObj Dim myObj
For Each myObj In oApplication.CurrentProject.AllForms For Each myObj In oApplication.CurrentProject.AllForms
Wscript.Echo "Exporting FORM " & myObj.FullName 'Wscript.Echo "Exporting FORM " & myObj.FullName
oApplication.SaveAsText acForm, myObj.FullName, sExportpath & "\" & myObj.FullName & ".form.txt" oApplication.SaveAsText acForm, myObj.FullName, sExportpath & "\" & myObj.FullName & ".form.txt"
oApplication.DoCmd.Close acForm, myObj.FullName oApplication.DoCmd.Close acForm, myObj.FullName
Next Next
For Each myObj In oApplication.CurrentProject.AllModules For Each myObj In oApplication.CurrentProject.AllModules
Wscript.Echo "Exporting MODULE " & myObj.FullName 'Wscript.Echo "Exporting MODULE " & myObj.FullName
oApplication.SaveAsText acModule, myObj.FullName, sExportpath & "\" & myObj.FullName & ".module.txt" oApplication.SaveAsText acModule, myObj.FullName, sExportpath & "\" & myObj.FullName & ".module.txt"
Next Next
For Each myObj In oApplication.CurrentProject.AllMacros For Each myObj In oApplication.CurrentProject.AllMacros
Wscript.Echo "Exporting MACRO " & myObj.FullName 'Wscript.Echo "Exporting MACRO " & myObj.FullName
oApplication.SaveAsText acMacro, myObj.FullName, sExportpath & "\" & myObj.FullName & ".macro.txt" oApplication.SaveAsText acMacro, myObj.FullName, sExportpath & "\" & myObj.FullName & ".macro.txt"
Next Next
For Each myObj In oApplication.CurrentProject.AllReports For Each myObj In oApplication.CurrentProject.AllReports
Wscript.Echo "Exporting REPORT " & myObj.FullName 'Wscript.Echo "Exporting REPORT " & myObj.FullName
oApplication.SaveAsText acReport, myObj.FullName, sExportpath & "\" & myObj.FullName & ".report.txt" oApplication.SaveAsText acReport, myObj.FullName, sExportpath & "\" & myObj.FullName & ".report.txt"
Next Next
For Each myObj In oApplication.CurrentDb.QueryDefs For Each myObj In oApplication.CurrentDb.QueryDefs
Wscript.Echo "Exporting QUERY " & myObj.Name 'Wscript.Echo "Exporting QUERY " & myObj.Name
oApplication.SaveAsText acQuery, myObj.Name, sExportpath & "\" & myObj.Name & ".query.txt" oApplication.SaveAsText acQuery, myObj.Name, sExportpath & "\" & myObj.Name & ".query.txt"
Next Next
For Each myObj In oApplication.CurrentDb.TableDefs For Each myObj In oApplication.CurrentDb.TableDefs
If Not Left(myObj.Name, 4) = "MSys" Then If Not Left(myObj.Name, 4) = "MSys" Then
Wscript.Echo "Exporting TABLE " & myObj.Name 'Wscript.Echo "Exporting TABLE " & myObj.Name
oApplication.ExportXml acExportTable, myObj.Name, , sExportpath & "\" & myObj.Name & ".table.txt" oApplication.ExportXml acExportTable, myObj.Name, sExportpath & "\" & myObj.Name & ".table.txt"
'put the file path as a second parameter if you want to export the table data as well, instead of ommiting it and passing it into a third parameter for structure only 'put the file path as a second parameter if you want to export the table data as well, instead of ommiting it and passing it into a third parameter for structure only
End If End If
Next Next
@ -119,7 +119,7 @@ Function exportModulesTxt(ACCDBFilename, sExportpath)
relFoTable.Text = myObj.ForeignTable relFoTable.Text = myObj.ForeignTable
relDoc.ChildNodes(0).LastChild.appendChild relFoTable relDoc.ChildNodes(0).LastChild.appendChild relFoTable
Wscript.Echo "Exporting relation " & myObj.Name & " between tables " & myObj.Table & " -> " & myObj.ForeignTable 'Wscript.Echo "Exporting relation " & myObj.Name & " between tables " & myObj.Table & " -> " & myObj.ForeignTable
For Each fld In myObj.Fields 'in case the relationship works with more fields For Each fld In myObj.Fields 'in case the relationship works with more fields
Dim lf, ff Dim lf, ff
@ -133,14 +133,14 @@ Function exportModulesTxt(ACCDBFilename, sExportpath)
ff.Text = fld.ForeignName ff.Text = fld.ForeignName
relDoc.ChildNodes(0).LastChild.LastChild.appendChild ff relDoc.ChildNodes(0).LastChild.LastChild.appendChild ff
Wscript.Echo " Involving fields " & fld.Name & " -> " & fld.ForeignName 'Wscript.Echo " Involving fields " & fld.Name & " -> " & fld.ForeignName
Next Next
End If End If
Next Next
If hasRelations Then If hasRelations Then
relDoc.InsertBefore relDoc.createProcessingInstruction("xml", "version='1.0'"), relDoc.ChildNodes(0) relDoc.InsertBefore relDoc.createProcessingInstruction("xml", "version='1.0'"), relDoc.ChildNodes(0)
relDoc.Save sExportpath & "\relations.rel.txt" relDoc.Save sExportpath & "\relations.rel.txt"
Wscript.Echo "Relations successfuly saved in file relations.rel.txt" 'Wscript.Echo "Relations successfuly saved in file relations.rel.txt"
End If End If
oApplication.CloseCurrentDatabase oApplication.CloseCurrentDatabase