Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making "Filters.Add" work in FilePicker

Status
Not open for further replies.

VBAGrandpa

Technical User
Sep 14, 2003
4
US
Hi everyone!

I have been scratching my head over this simple problem for too long. Here's my VBA code (in Excel 2002):

With Application.FileDialog(msoFileDialogFilePicker)
.Filters.Clear
.Filters.Add "Photos", "*.jpg; *.gif; *.bmp, 1"
.InitialFileName = PhotosPath
.Title = "Select a photo to use"
.AllowMultiSelect = False
.Show
End With

The problem is the the file dialog comes up with the default "All Files *.*", totally ignoring my Filters.Add specification. Can anyone tell me what stupid mistake I am making here?

Thanks in advance
Dave G
 
Hey VBAGrandpa -- ME TOO! :)

try the GetOpenFilename method
Code:
    fileToOpen = Application _
        .GetOpenFilename("Photos (*.bmp;*.gif;*.jpg), *.bmp;*.gif;*.jpg")
    If fileToOpen <> False Then
        MsgBox &quot;Open &quot; & fileToOpen
    End If
:)



Skip,
Skip@TheOfficeExperts.com
 
Thanks, Skip.

Does this mean that the method I have been trying to use can't do the file filtering I need?

Dave G
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top