Solved

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

Posted on 2014-10-20
2
3,556 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now