Jim Pockmire said:
In your code below, can "ALLForms, AllMacros, etc. be used as
variables in "CurrentProject" to reuse the same code?
Not readily. The best I've been able to figure out is something like
this:
'----- start of code -----
Sub ExportObjects(ot As AcObjectType, OutFile As String)
Dim c As AllObjects
Dim ao As AccessObject
Select Case ot
Case acForm: Set c = CurrentProject.AllForms
Case acReport: Set c = CurrentProject.AllReports
Case acModule: Set c = CurrentProject.AllModules
Case acMacro: Set c = CurrentProject.AllMacros
Case acDataAccessPage: Set c = CurrentProject.AllDataAccessPages
Case acTable: Set c = CurrentData.AllTables
Case acQuery: Set c = CurrentData.AllQueries
Case Else
Err.Raise 5, "ListCollection", "Unsupported object type"
End Select
For Each ao In c
DoCmd.TransferDatabase _
acExport, _
"Microsoft Access", _
OutFile, _
ot, _
ao.Name, _
ao.Name
Next ao
Set c = Nothing
End Sub
'----- end of code -----
You'd then call it like this:
ExportObjects acForm, "C:\Temp\Output.mdb"
ExportObjects acReport, "C:\Temp\Output.mdb"
ExportObjects acModule, "C:\Temp\Output.mdb"
ExportObjects acMacro, "C:\Temp\Output.mdb"
ExportObjects acDataAccessPage, "C:\Temp\Output.mdb"
ExportObjects acTable, "C:\Temp\Output.mdb"
ExportObjects acQuery, "C:\Temp\Output.mdb"