Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

multiple file masks on dir$()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
larrysulky@gmail.com - 21 Sep 2006 14:02 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 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/


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.