GetOpenFileName - filter list based on part of the file pref

turbotoan

Board Regular
Joined
Feb 25, 2002
Messages
62
I have a need to use the GetOpenFileName method, to select a file.

The default directory where the files are stored have different names....
123_ABC.txt
333_ABC.txt
999_WYZ.txt

I can use the FileFilter property to narrow down *.txt files.

But I need to only display the _ABC.txt files. I can get it to work only manually through the dialog...i.e. type in: 'ABC.txt' should filter the list in the dialog to: 123_ABC.txt & 333_ABC.txt

Does anyone know how to programatically match the file name just like the "File name" option in the dialog box itself?

The provided example via this link did not work:
http://mrexcel.com/board/viewtopic.php?topic=6480&forum=2

When we run it, we see the following in the
Files of Type drop-down list:
my Files(*_ABC.txt.*)

We also tried it without the last ".", but it just displayed:
my Files(*_ABC.txt*)

However, no files defined of that type display. Any suggestions would be great.
Perhaps this filter should be applied to the "File Name" entry box instead?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Your file filter needs to be defined as;

sFilter = "my Files (*ABC.txt)" & Chr(0) & "*ABC.txt" & Chr(0)
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,974
Members
448,934
Latest member
audette89

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