Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Csv files

Status
Not open for further replies.

marko23

MIS
Mar 27, 2006
5
GB
Hello Guys,

Im really hoping someone can help me,

I have a load of Excel csv files that Im trying too import into Access, I just wondered if anyone knows a macro or a VBA automation way of importing multiple csv files into access?

You would really appreciate someones help on this

Thanks

Markus
 
The best luck I've had with this is using a Schema.ini file that looks something like:
Code:
[Sales.txt]
ColNameHeader=FALSE
CharacterSet=OEM
Format=CSV
Col1=ProdPart Char 
Col2=UsedPart Char 
Col3=UsedPct Char 
Col4=Decimals Char 
Col5=RtvDate Char

If all your files are in the same folder, and they're all going into the same target table, you could use the File System Object and loop through the files, executing something like:
Code:
    wrkName = "Sales.txt"
    cmdUpdate = "insert into SalesImport select * from [Text;database="
    cmdUpdate = cmdUpdate + ProjectPath + "]." + wrkName
    dbQuery.Execute cmdUpdate, dbFailOnError
NOTE: the program variable ProjectPath does not have a trailing back-slash.

HTH


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top