问题
I am looking for a VBA code to run multiple saved imports in MS Access 2010. I used DoCmd.RunSavedImportExport "*"
but gave an error.
I know I am doing something wrong here. Please understand I am a newbie to VBA. I have almost 8 saved imports in .csv formats in a specific location. All I want is to automate it through VBA.
回答1:
i guess you have taken all other necessary steps already. loop through the saved import/export and execute them one by one. something like:
pseudo would be: loop through the import/export and execute it manually.
in code would be:
Dim i As Integer
For i = 0 To CurrentProject.ImportExportSpecifications.count - 1
Debug.Print CurrentProject.ImportExportSpecifications(i).name
DoCmd.RunSavedImportExport CurrentProject.ImportExportSpecifications(i).name
Next i
EDIT
Your ImportExportSpecifications details are saved as XML format and you can access that information via
CurrentProject.ImportExportSpecifications(i).XML
within the XML you will find the path = "your file.xlsx". Do a string job to extract the path and validate the file ending and implement your code.
来源:https://stackoverflow.com/questions/29838811/ms-access-vba-to-run-all-saved-imports-together