Hi, I'm having a problem, not sure if it's VBA related or if there's something wrong with my system. I have the following code:
Sub test()
Set fs = Application.FileSearch
With fs
.NewSearch
.FileType = msoFileTypeExcelWorkbooks
.LookIn = "\\directory\"
.Filename = "3000333*"
If .Execute > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub
It looks into a specific directory, and tells me how many files beginning with 3000333 there are in that folder. I have over a thousand files in the folder, 13 of which begins with 3000333. However, according to this code, it only finds 10. However, if i just use .Filename = "*.*" , that is, search for all the files in the directory, then I get all the files, including the three that did not appear.
Here are the 13 files that should appear:
30003330x051206.XLS
30003332x051606.XLS
30003333x071206.XLS
30003334x071206.XLS
30003335x021706.XLS
30003335x040706.XLS
30003337x041006.XLS
30003337x061506.XLS
30003338x042506.XLS
30003339x012506.XLS
30003339x021606.XLS
30003339x022306.XLS
30003339x031606.XLS
However, the code does not find 30003333x071206.XLS, 30003334x071206.XLS, and 30003337x041006.XLS.
Any suggestions?
Bookmarks