Hi
Copy the function GetMyFile() from below into workbooks module.
P.e. into cell A2 enter the formula like:
=IF(GetMyFile("C:\Documents and Settings\User\My
Documents\";ROW()-1;"xls")=0;"";GetMyFile("E:\Documents and Settings\User\My
Documents\";ROW()-1;"xls"))
and copy it down for at least as much rows, as you have files of type, you
are searching for, in this folder.
Additionally below is the function GetSubFolder(), which allows you to
create a list of subfolders for determined folder. You can combine both
functions, to ge a table of files in subfolders of some certain folder.
Arvi Laanemets
*****
Public Function GetSubfolder(MyFolder As String, FolderNum As Integer)
Dim fs, f, f1, s, sf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(MyFolder)
Set sf = f.SubFolders
i = 0
For Each f1 In sf
i = i + 1
If i = FolderNum Then GetSubfolder = f1.Name
Next
End Function
Public Function GetMyFile(MyFolder As String, FileNum As Integer,
MyExtension As String)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(MyFolder)
Set fc = f.Files
i = 0
For Each f1 In fc
If Right(f1.Name, 3) = MyExtension Then
i = i + 1
If i = FileNum Then GetMyFile = f1.Name
End If
Next
End Function