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

Nelson78

Active Member
Joined
Sep 11, 2017
Messages
488
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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Nelson78

Active Member
Joined
Sep 11, 2017
Messages
488
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.

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...
 

Watch MrExcel Video

Forum statistics

Threads
1,132,896
Messages
5,655,850
Members
418,247
Latest member
The_aze

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
Top