Sub fileDlg()
Dim fd As FileDialog
Dim imagePath As String
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "All files", "*.*"
.Filters.Add "Image", "*.jpg", 1
.FilterIndex = 1
.InitialFileName = ""
.Title = "Select JPEG file"
If .Show = -1 Then 'User pressed action button
imagePath = .SelectedItems(1)
End If
End With
End Sub
|