FileSearch strictness issue
Posted
by JakeTheSnake
on Stack Overflow
See other posts from Stack Overflow
or by JakeTheSnake
Published on 2009-10-31T20:03:48Z
Indexed on
2010/05/25
0:01 UTC
Read the original article
Hit count: 268
I'm currently trying to search directories for any file labelled "??.??.????.xls" (for mm.dd.yyyy.xls). The problem I have is that the code I'm using also matches filenames such as "my-restaurant.12.01.2006.xls". I only want to match filenames with specifically the notation I used above.
Dim Invoices As FileSearch
Set Invoices = Application.FileSearch
With Invoices
.Filename = "??.??.????.xls"
' invDir is a directory I chose earlier on
.LookIn = invDir
.SearchSubFolders = True
.MatchTextExactly = True
End With
Is there something I'm missing? I know I could do yet another check in my code elsewhere to make sure the filename's length is 14 characters, but is there a parameter I'm not considering in the FileSearch?
© Stack Overflow or respective owner