Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4169
  • Last Modified:

Access VBA Loop through csv files in a folder and import using an import specification

Hi

What Access VBA code would I use to loop through csv files in a folder and import using an import specification?
0
Murray Brown
Asked:
Murray Brown
1 Solution
 
slubekCommented:
I'm using something like that:
Public Const rootdir = "c:\Data\"

Sub import()
    Dim nr as int
    file = Dir$(rootdir & "*.csv")
    nr = 1
    Do While file <> ""
	DoCmd.TransferText acImportDelim, "ImportSpec", "NewTableName-" & nr, rootdir & file, True, , msoencodingCentralEuropean
	file = Dir$
	nr = nr + 1
    Loop
End Sub

Open in new window

0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now