Set File = Application.FileDialog(msoFileDialog
FolderPicker)
Well, one thing is you are using the FOLDER picker option instead of the file picker option - "msoFileDialogFilePicker"
Here is the code I use. I did modify it a little for you...... <snip> means I cut out code that didn't apply to you.
Code:
<snip>
Dim d As DAO.Database
Dim strFileName As String
Dim fd As FileDialog
Set d = CurrentDb
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Title = "Select Beginning Balances file to import" '1) To set the caption of the dialog box, set the Title property
.InitialFileName = CurrentProject.Path '2) Set the oddly named InitialFileName property to determine the initial folder selected
.InitialView = msoFileDialogViewDetails '3) Set the InitialView property to control how your files appear on screen (as a list, icons, etc.)
.AllowMultiSelect = False
.Filters.Clear '4) To set the filters (you can have as many as you like) first clear any existing ones, then add them one by one
'what I use
' .Filters.Add "CSV Files", "*.csv"
' .FilterIndex = 1 ' if there's more than one filter, you can control which one is selected by default
' .ButtonName = "Choose CSV file" '5) Set the ButtonName property to control the text on
'for you
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg", 1 ' if there's more than one filter, you can control which one is selected by default
.ButtonName = "Choose Image file" '5) Set the ButtonName property to control the text on the button.
If .Show = -1 Then
strFileName = .SelectedItems(1) ' get the file name & path
' MsgBox strFileName 'display name and path of file chosen
Else
MsgBox "You chose cancel" 'didn't choose anything (clicked on CANCEL)
Set d = Nothing
Exit Sub
End If
End With
If Len(Trim(strFileName & "")) > 0 Then
<snip>