import multiple text files using VBA - For Next or do until...

  • Thread starter Thread starter EmOxon
  • Start date Start date
E

EmOxon

Hi,
I need to import a number of files using predefined import specs
using. I would like to use For...next loop in VBA to minimize the code
and the table with names of the files. Any help will be greatly
appreciated.

Thanks
 
Hi,
I need to import a number of files using predefined import specs
using. I would like to use For...next loop in VBA to minimize the code
and the table with names of the files. Any help will be greatly
appreciated.

Thanks

If the paths to the files are stored in a table already, you can do
something like this:

Private Sub Command0_Click()
Dim strFile As String

strFile = Dir("C:\*.*")

Do Until strFile = ""
Debug.Print strFile
strFile = Dir
DoCmd.TransferText acImportDelim, "MySavedSpecName",
"DestinationTable", strFile, False
Loop


End Sub
 
Back
Top