Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Still need help counting files? 1

Status
Not open for further replies.

ribhead

Technical User
Jun 2, 2003
384
US
I just copied this from the Help File at work. I take it I'm missing some code here?

Sub whatthe()
With Application.FileSearch
.LookIn = "h:"
.Filename = "*.xls"
.SearchSubFolders = True
MsgBox .FoundFiles.Count
End With
End Sub
Any help would be great!!!

For just $19.95 you too can have a beautiful smile.
 
You don't need to specify the extension in the FileName property. The piece you omitted is the .Execute:
Code:
Sub whatthe()
With Application.FileSearch
    .NewSearch
    .LookIn = "c:\my documents"
    .Filename = "*"
    .SearchSubFolders = False
    .MatchTextExactly = False
    .FileType = msoFileTypeExcelWorkbooks
    .Execute
MsgBox .FoundFiles.Count
End With
End Sub

Dan.
 
Thanks a bunch Dan the Man. Wors Great!!!!

For just $19.95 you too can have a beautiful smile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top