Use VBA to link a semi colon delmited csv file

JazzSP8

Well-known Member
Joined
Sep 30, 2005
Messages
1,233
Office Version
  1. 365
Platform
  1. Windows
Hey All

I'm trying to use VBA to link a "csv" file as a table that has semi colons as a delimiter.

If I use 'External Data > New Data Source > From File > Text File' and set the semi colon as the delimeter then it links as I'd expect it to do.

I can get the file to link using VBA but all the data appears in one field.

I've been Googling around and apparantly I needed to create a "schema.ini" file to be able to use the semi colon as a delimiter, which I've tried to do but it doesn't seem to be working.

This is what I've got;

VBA Code:
Sub FnB()

    Open CurrentProject.Path & "\schema.ini" For Output As #1
        Print #1, "[All Attributes.csv]"
        Print #1, "ColNameHeader=True"
        Print #1, "Format=Delimited(;)"
    Close #1
    
    DoCmd.TransferText TransferType:=acLinkDelim, TableName:="FnB", FileName:=CurrentProject.Path & "\All Attributes.csv", HasFieldNames:=True
    
End Sub

I've tried variations on a theme but I can't get it to work - The code above is what I think should work based on what I read but I seem to be missing something, somewhere.

Thanks for looking.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Nevermind, the answer was there all along;


Thanks from the future, @smozgur
 
Upvote 0
Solution

Forum statistics

Threads
1,223,883
Messages
6,175,167
Members
452,615
Latest member
bogeys2birdies

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