Thread: Dir
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Dir

I think he meant this:

Public Sub test2()


Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
ActiveCell.Formula = nbFiles("C:\users", fs)


End Sub


Private Function nbFiless(folderName As String, ByRef fs As Object)


Dim f As Object


nbFiles = fs.GetFolder(folderName).Files.Count


If Not (fs Is Nothing) Then
If fs.GetFolder(folderName).SubFolders.Count 0 Then
For Each f In fs.GetFolder(folderName).SubFolders
nbFiles = nbFiles _
+ nbFiles(f.Path, fs)
Next
End If
End If
End Function




--
Regards,
Tom Ogilvy

"greasybeano" wrote in message
...
thanks for reply but could not see anything from link provided that would
assist me.
--
GB


" wrote:

On Sat, 27 May 2006, greasybeano wrote:

I have taken the following code from the Dir help file which works ok

at
first level.
However, I need to search for all the associated subdirectories but

not too
sure how to adapt the code. could someone be kind enough to assist

please?

You may be interested by Application.FileSearch
and fs.GetFolder(folderName)
where fs is a FileSystemObject


http://groups.google.com/group/micro...3f3d25661 7ef