Hi
This UDF returns name of n-th file with given extension in given folder.
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
P.e. into cell A1 enter the formula like this:
=IF(ISERROR(GetMyFile("C:\My Music\",ROW(),"mp3")),"",GetMyFile("C:\My
Music\",ROW(),"mp3"))
and copy it down
Arvi Laanemets
"Rob McLean" wrote in message
...
I have many MP3s on my hard drive, and I'd like to download the filenames
directly into Excel. Is there a quick way to do this? Or would I have to
copy-and-paste them one at a time?
|