MS Access VBA to run all saved imports together

孤街醉人 提交于 2020-08-11 05:06:45

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!