Hej
Har fundet denne:
(Afprøvet i Excel-2003)
Bemærk: Range("A1:A1000").ClearContents
Forbereder til liste
Antal i B1.
Sub filliste()
Dim FS As FileSearch
Dim FilePath As String, FileSpec As String
Dim i As Long, t As Integer
Dim v As Variant
Dim rTarget As Range
Dim ToSheet As Worksheet
'******************************
FilePath = ThisWorkbook.Path
FileSpec = "*.xls"
Set ToSheet = ThisWorkbook.Worksheets("ark1")
'******************************
'find excel filerne
Set FS = Application.FileSearch
With FS
.LookIn = FilePath
.Filename = FileSpec
.SearchSubFolders = False 'skal underfoldere også søges
.Execute
If .FoundFiles.count = 0 Then
MsgBox ("Ingen filer fundet")
Exit Sub
End If
End With
Range("A1:A1000").ClearContents
Range("A1") = "antal filer:"
Range("B1") = FS.FoundFiles.count
For i = 1 To FS.FoundFiles.count
For t = 1 To Len(FS.FoundFiles(i))
If Mid(FS.FoundFiles(i), t, 1) = "\" Then sidst = t
Next t
ToSheet.Range("A1").Offset(i, 0) = Mid(FS.FoundFiles(i), sidst + 1, Len(FS.FoundFiles(i)) - sidst)
Next i
End Sub
Lavet af: jlemming d. 29. november 2007
http://www.eksperten.dk/spm/808097mvh
Morten