VBA: how to open the only .csv file existing in a directory

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
Hello everybody.

I've the following directory in my pc:

Code:
R:\Users\john.smith\Downloads

It contains two files, only one of them is a .csv. But, about it, I don't know the exact name.

How can I open it exploiting the only information I have? (it is a .csv file).

Thank's.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hello everybody.

I've the following directory in my pc:

Code:
R:\Users\john.smith\Downloads

It contains two files, only one of them is a .csv. But, about it, I don't know the exact name.

How can I open it exploiting the only information I have? (it is a .csv file).

Thank's.

I've tried this way:

Code:
Workbooks.Open ("R:\Users\john.smith\Downloads\*.csv")

but it is opened without text to columns. On the contrary, if I open it manually the text is to columns like a normal .xls file...
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,144
Members
453,021
Latest member
Justyna P

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