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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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,214,653
Messages
6,120,752
Members
448,989
Latest member
mariah3

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