Application.FileSearch virker ikke
Jeg vil gerne finde filer i et subdirectoryFandt følgede kode på nettet.
'Application.FileSearch'
giver følgende fejl
'run-time error 445
Object doesn't support this action'
Hvad kan årsagen være.
Heller ikke
directoryInfo genkendes af vba
Sub List_All_The_Files_Within_Path()
Dim Row_No As Integer
Dim No_Of_Files As Integer
Dim kk25 As Integer
Dim File_Path As String
File_Path = "C:\My Documents"
Row_No = 36
'Lists all the files in the current directory
With Application.FileSearch
.NewSearch
.LookIn = File_Path
.Filename = "*.*"
.SearchSubFolders = False
.Execute
No_Of_Files = .FoundFiles.Count
For kk25 = 1 To No_Of_Files
Worksheets("Sheet1").Cells(kk25 + 5, 15).Value = .FoundFiles(kk25)
Next kk25
End With
End Sub