Solved File Dialog Filter using variable (1 Viewer)

mjdemaris

Working on it...
Local time
Yesterday, 20:29
Joined
Jul 9, 2015
Messages
426
Greetings,

Is it possible to use a variable for the dialog filter, i.e.: strFilter set when the function is called via button click, instead of "*.pdf"?

I would like the user to be able to select which type of file they want to add, but the Filters property does not like my string variable.

Thank you.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:29
Joined
Oct 29, 2018
Messages
21,471
Yes, I think so, but you'll probably need to use two string variables. Just a guess...
 

mjdemaris

Working on it...
Local time
Yesterday, 20:29
Joined
Jul 9, 2015
Messages
426
Yes, I think so, but you'll probably need to use two string variables. Just a guess...

As in:
Code:
.Filters.Add strFileTitle, strFilter
?

Code:
.Filters.Add "PDF File", strFilter
simply throws an error: Error 5: Invalid procedure call or argument.
 

Isaac

Lifelong Learner
Local time
Yesterday, 20:29
Joined
Mar 14, 2017
Messages
8,777
Microsoft's website gives this as one example:
Code:
.Filters.Add "Access Databases", "*.MDB"
The part:
"*.MDB"

....is a literal string. Thus, I think right there you could use a string variable, which equates to *.pdf or whatever
 

mjdemaris

Working on it...
Local time
Yesterday, 20:29
Joined
Jul 9, 2015
Messages
426
Microsoft's website gives this as one example:
Code:
.Filters.Add "Access Databases", "*.MDB"
The part:
"*.MDB"

....is a literal string. Thus, I think right there you could use a string variable, which equates to *.pdf or whatever

Check my edits just above, as I added this in.
 

mjdemaris

Working on it...
Local time
Yesterday, 20:29
Joined
Jul 9, 2015
Messages
426
Oh dang...

I had two versions of code using file dialogs, somewhat integrated, and one version specified using ".pdf" rather than "*.pdf"...

Oops! Where's the face palm when you need it? Thanks guys, sometimes just a quick discussion is all it takes to see the obvious mistakes!

Well, now an example with filter variables exist, lol!
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:29
Joined
Oct 29, 2018
Messages
21,471
Oh dang...

I had two versions of code using file dialogs, somewhat integrated, and one version specified using ".pdf" rather than "*.pdf"...

Oops! Where's the face palm when you need it? Thanks guys, sometimes just a quick discussion is all it takes to see the obvious mistakes!

Well, now an example with filter variables exist, lol!
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom