Solved

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

Posted on 2014-10-20
2
3,761 Views
Last Modified: 2014-10-21
Hi

What Access VBA code would I use to loop through csv files in a folder and import using an import specification?
0
Comment
Question by:murbro
2 Comments
 
LVL 7

Accepted Solution

by:
slubek earned 500 total points
ID: 40393678
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
 

Author Closing Comment

by:murbro
ID: 40394226
Thanks
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question