UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> File Dialog Filter    
 
   
KantWin
post Jan 15 2011, 10:18 AM
Post #1

UtterAccess Guru
Posts: 547
From: Alabama



Howdy!

I'm using the Application.FileDialog to browse for a file, but I'm having a problem with a filter.
I need to filter not only by the type (that's easy!), but by a partial file name.
I would like to have it filter and only show the files that end with "Tables.mdb".

Partial code below
CODE
Dim f As Object

Set f = Application.FileDialog(3)
f.Title = "Please browse for the file"
f.Filters.Clear
f.Filters.Add "Table File", "*Tables.MDB"
f.Show


It errors on the f.Filters.Add line, with Invalid procedure call or argument.
I have searched and searched, but can't seem to find a solution.
Any help would be appreciated.
Go to the top of the page
 
+
KantWin
post Jan 17 2011, 10:02 AM
Post #2

UtterAccess Guru
Posts: 547
From: Alabama



I believe I have found the answer, using InitialFileName.
I had tried that before, but I found that if I also add a filter, it doesn't use the complete InitialFileName. That's what was frustrating me.
For example, if I set the InitialFileName as "*Tables.mdb", and also set a filter for "*.mdb", the InitialFileName would only show "*Tables"
Once I removed the filter, and had only "All Files", "*.*" as the filter, it worked.

Here's what I used that worked.
CODE
    Dim f As Object
    Dim strFolderPath As String

    Set f = Application.FileDialog(3)
    f.Title = "Please browse for the file"
    f.Filters.Clear
    strFolderPath = Application.CurrentProject.path
    f.InitialFileName = ""
    f.InitialFileName = strFolderPath & "\*Tables.mdb"
    f.Filters.Add "All Files", "*.*"
    f.Show
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 21st May 2013 - 11:22 PM

Tag cloud: