import CSV files into new tables

ashwinghanta

Board Regular
Joined
Dec 6, 2011
Messages
118

I am trying to import CSV files located in a folder into Access as new tables and I have been trying with a code

<tbody>
</tbody>



I am trying to import CSV files located in a folder into Access as new tables and I have been trying with a code

Code:
Public Const rootdir = "C:\Users\deb670s\Desktop\importcsv"


Sub import()
    Dim nr As Integer
    Dim file As AcBrowseToObjectType
    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

But I get an error saying variable not defined at msoEncodingCentralEuropean Can someone tell me where am I going wrong?

<tbody>
</tbody>
 
Last edited:
I have changed the location of the folder. I think it was causing a problem with Users as I'm using a German windows system. I'd like to thank you for the help
I see that you dropped the extra last argument in TransferText like I mentioned too. I think that was an issue also, as it seems you only use that optional argument with HTML files, which you are not using.
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,221,810
Messages
6,162,108
Members
451,743
Latest member
matt3388

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top