Hi. I searched but couldn't find an answer to or example of this. Is it
possible to specify multiple file masks on a single call to dir$()? I
have:
theFile = Dir$(TemplatePath & "*.bas")
but what I'd really like is something like:
theFile = Dir$(TemplatePath & "*.bas" | TemplatePath & "*.frm")
That is, the file mask should constrain to either *.bas or *.frm. Or
can I do something like
theFile = Dir$(TemplatePath & "*.bas") & Dir$(TemplatePath & "*.frm")
? It sure seems possible but the syntax is defeating me.
TIA
---larry
Helmut Weber - 21 Sep 2006 15:13 GMT
Hi Larry,
>Is it possible to specify multiple file masks on a single call to dir$()?
not to my knowledge.
If you have or want to use dir,
for which there may be good reasons,
then I'd code my own filter.
Or use something rather primitive:
Dim sTmp As String
sTmp = Dir("c:\test\word\" & "*.xls")
If sTmp = "" Then
sTmp = Dir("c:\test\word\" & "*.txt")
End If
MsgBox sTmp

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Karl E. Peterson - 21 Sep 2006 19:00 GMT
> Hi. I searched but couldn't find an answer to or example of this. Is
> it possible to specify multiple file masks on a single call to
[quoted text clipped - 5 lines]
>
> theFile = Dir$(TemplatePath & "*.bas" | TemplatePath & "*.frm")
Not directly, no. But I've coded up a class module that handles this pesky
detail, as well as recursive folder navigation, pretty neatly. See
http://vb.mvps.org/samples/DirDrill to give it a try.

Signature
Working without a .NET?
http://classicvb.org/