View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default counting xls files in a folder

Note the slash after the folder name
strFolder = "c:\temp\"

If this post helps click Yes
---------------
Jacob Skaria


"dstiefe" wrote:

it didn't work...



"Jacob Skaria" wrote:

Have you tried the DIR option i posted///
--
If this post helps click Yes
---------------
Jacob Skaria


"dstiefe" wrote:

someone had given me this code... (see below)...but the "filesearch" option
does not pop up when I start typing the code.. I am using 2007 version...will
that make a difference?

Thank you

Here is another method

Sub test()
folder = "c:\temp"

Set FS = Application.FileSearch
With FS
.NewSearch
.LookIn = folder
.SearchSubFolders = False
'.Filename = "Run"
'.MatchTextExactly = True
.FileType = msoFileTypeExcelWorkbooks

FileCount = .Execute

If FileCount 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
Else
MsgBox "There were no files found."
End If

End With


End Sub