Dynamically Determine Delimited File Using VBA?

bhoffste

New Member
Joined
Apr 22, 2003
Messages
26
This question could go in Access or Excel, but since I'm working in Access, I've plopped it here...

I am creating an automated process to import a bunch of text files into Access. I want to avoid creating a separate "Spec" for each file (there are over 180 files) and instead want to code my own dynamic importing rules. So far it's been going fine, except for one item...

I can't figure out a reliable way to determine in VBA whether a given text file is comma-delimited, tab-delimited, etc. Obviously there is nothing inherent in the file's properties, at least as far as I know. Sometimes the extension is the ticket (e.g. "csv" usually means comma-delimited), but that's not always reliable, since "txt" could mean a million things. The only thing I can think of is to open the file via IO and come up with some logic (e.g. if each line contains a certain number of commas, then assume the file is comma-delimited), but that too sounds like a half-baked method.

I am hoping that I'm just missing something incredibly obvious and can benefit from the great minds in this forum. Thanks in advance for any ideas.

- Ben
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,221,574
Messages
6,160,602
Members
451,657
Latest member
Ang24

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