Costas
Member
Hi Chandoo,
I'm trying to filter the files that show on the open dialog box to include certain strings but also to be csv type.
Using the code below, the string filters work but not the file type. I've also tried to only filter on the file type but then I get all the csv files.
Is it a case of either or between file name and file type or can I apply both filters?
I'm trying to filter the files that show on the open dialog box to include certain strings but also to be csv type.
Using the code below, the string filters work but not the file type. I've also tried to only filter on the file type but then I get all the csv files.
Code:
MyPath = ThisWorkbook.Path
ChDir MyPath
With Application.FileDialog(msoFileDialogFilePicker)
.Filters.Clear
.InitialFileName = "*" & MySubName & "*" & MyLocation & "*.csv"
.AllowMultiSelect = False
'Filter file extension types
.Filters.Add "Comma-Separated Value Files", "*.csv", 1
.FilterIndex = 2
'Show the dialog box
.Show
On Error GoTo ErrorHandler
MyFullPath = .SelectedItems.Item(1)
End With
Is it a case of either or between file name and file type or can I apply both filters?