FileSearch doesn't?

M

Maury Markowitz

I have a folder that we dump text files from our counterparties into.
One of these is named something like...

"038157657_8671_(big timestamp).zip"

I know the date, "today", but I obviously don't know what time they
created the report, so when I want to open the file I want to do a
wildcard search on ""038157657_8671_10222008". Here's how I'm doing
this...

Set fs = Application.FileSearch
fs.NewSearch
fs.LookIn = "O:\downloads\"
fs.SearchSubFolders = False
fs.filename = "*038157657_8671_*.*"
fs.Execute

This fails, returning zero files. It DOES work if the file in question
is a csv, but not if it's a zip. I'm flailing here, but is FileSearch
interpreting the zip file as a folder?

Any suggestions?

Maury
 
S

Steve Sanford

Hi Maury,

I don't see anything wrong with your code.

I threw together a test routine. I created three files with 3 differences
extensions: doc, xls & zip. It returned all of then.

here is the code:

'------------------------------------
Option Compare Database
Option Explicit

Public Sub TestFileSearch()
Dim fs As FileSearch
Dim i As Integer
Dim str As String

str = "No files found"

Set fs = Application.FileSearch
With fs
.NewSearch
.LookIn = "C:\Documents and Settings\Administrator\My Documents\"
.SearchSubFolders = False
.FileName = "*038157657_8671_*.*"
.Execute

If .FoundFiles.Count > 0 Then
str = .FoundFiles.Count & " files found" & vbCrLf & vbCrLf
For i = 1 To .FoundFiles.Count
str = str & .FoundFiles(i) & vbCrLf
Next i
End If
End With
MsgBox str
End Sub
'------------------------------------


HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top