Hello,
The following code does in fact import records contained in the Excel files contained within a given folder. The Excel files are all named using the following naming convention:
- ExportProd1
- ExportProd2
- ExportProd3, etc. (all the way to 'ExportProd75')
However, it gets caught in a vicious loop where it repeatedly imports only records from the 'ExportProd1', 'ExportProd10', 'ExportProd11', 'ExportProd12', and 'ExportProd13' Excel files. My total record count from all 75 files is around 2.4 million.
The looping activity caused the total to grow in excell of 11 million before the database crashed.
Here is the code. Why is it looping like that instead of going through all 75 files within the folder in order? All files are uniquely named:
Option Compare Database
Function Impo_allExcel()
Dim myfileDim mypathmypath = "C:\PDooley_Projects\CompanyName\Customer_Integration\Oracle_export"Domyfile = Dir(mypath & "*.xls")'this will import ALL the excel files (one at a time, but automatically) in this folder. Make sure that's what you want.DoCmd.TransferSpreadsheet acImport, 8, "Contacts_AVDC_NEW", mypath & myfilemyfile = DirLoop Until myfile = ""
End Function
I do hope I can adjust this code to prevent this looping, otherwise, I will have to import every single Excel file into my Access database one at a time.
Thank you.