View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nate Oliver[_3_] Nate Oliver[_3_] is offline
external usenet poster
 
Posts: 71
Default .filesearch trouble

Hello,

The following works for me:

Sub FilTime()
Dim myFolders As Variant, i As Long, j As Long
Dim fileList() As String
Let myFolders = [{"c:\temp","p:\data"}]
With Application.FileSearch
.NewSearch
'Create string: "c:\temp;p:\data"
.LookIn = Join$(myFolders, ";")
.SearchSubFolders = False
.Filename = "*.csv"
If .Execute() 0 Then
ReDim Preserve fileList(1 To .FoundFiles.Count)
For j = 1 To UBound(fileList)
fileList(j) = .FoundFiles(j)
Next j
Else: MsgBox "There were no files found."
End If
End With
If j Then
For i = LBound(fileList) To UBound(fileList)
Debug.Print fileList(i)
Next
Debug.Print UBound(fileList)
End If
End Sub

You could use join() (if you have xl 2000+) to convert your array to a
string to search on if you must start with an array.

Regards,
Nate Oliver