# Thread: File dialog box shows all file types rather than selected file types

1. ## File dialog box shows all file types rather than selected file types

Code is:
Code:
```    '   get code for pic
Dim vFile, sPath2Pics, FileChosen
vFile = file
sPath2Pics = CurrentProject.Path
With Application.FileDialog(msoFileDialogFilePicker)
.Filters.Clear
FileChosen = .Show
.Title = "Choose File"
.InitialFileName = sPath2Pics & "\pics\"

.InitialView = msoFileDialogViewList
.Filters.Clear

.ButtonName = "Choose this file"
.AllowMultiSelect = False
.FilterIndex = 1

If FileChosen <> -1 Then
MsgBox "No file chosen !!"
Else
file = .SelectedItems(1)
End If
End With```
The above code shows all files (*.*) in the file dialog box, why is this so?
What does .FilterIndex = 1 do?

2. As it turns out i have solved it by replacing:
to

The All file *.* in the file types at the bowwom don't matter

3. I'm surprised you fixed it like that way, the basic problem is that your initial code shows the dialog before you set it's properties. Set the properties then show the dialog just before you test the return value.

Setting FilterIndex tells the dialog which filter, when you provide multiple filters, is the default. i.e. the one selected before the user drops down the list of filters and selects another.

Ian.

4. Thanks Ian, would you change my code and let me know what you mean please
No matter i did the following:
Code:
```         .Title = "Choose File"
.InitialFileName = sPath2Pics & "\pics\"

.InitialView = msoFileDialogViewList
.Filters.Clear