VBA - File picker , XLSX & CSV

JoeRooney

Board Regular
Joined
Nov 27, 2017
Messages
173
Office Version
  1. 365
Hi,

I am having an issue with the below piece of code for myfile picker , it is working fine for excel files but the csv files are notvisable when the file picker is open.

Is there any way of being able select either a csv or xlsxfile through a file picker?

Any help is greatly appreciated

Thanks


fNameAndPath =Application.GetOpenFilename(FileFilter:="Excel Files (*.XLSx), *.XLS,,*.CSV", Title:="Select File To Be Opened")
If fNameAndPath = False Then Exit Sub
Set wb = Workbooks.Open(fNameAndPath)
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
When I use your code, and the browser both opens up, there is a "File Name" box at the bottom of the screen, and just to the right of that is another drop-down box that is set to: "Excel Files (*.XLSx)".
If I click on the arrow in the drop-down box, I can change the value to "(*.CSV)", which then shows all the CSV files.
 
Upvote 0
Thanks sorry I see that now, I can select the CSV files but where it says "Excel files" in the Dropdown box it is blank for the CSV files , I can still select just the text is blank.

I am not to worried about that though as long as can select them.
 
Upvote 0
That's odd - it shows for me.
Maybe it is a due to a different version of Excel, or something like that.
 
Upvote 0
Try this.
Code:
    fNameAndPath = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.XLS*,CSV FIles (*.csv),*.CSV", Title:="Select File To Be Opened")
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
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