protegeone
11-19-2006, 08:45 AM
Hi Everyone :hi: ,
Still a beginner, ( not giving up though )..
The below code works fine, but could not make it list only the name of the found file(s).
Ideally the result should only be the name of the file, without the extension and path.
Private Sub listfiles()
Set pa = Application.FileSearch
With pa
.LookIn = "C:\Downloads\Bucsai"
.SearchSubFolders = True
.Filename = "*.pdf"
If .Execute(SortBy:=msoSortByFileName) = 1 Then
For i = 1 To .FoundFiles.Count
Range("A500").End(xlUp).Offset(1, 0).Value = .FoundFiles(i)
Next i
ElseIf .Execute(SortBy:=msoSortByFileName) > 1 Then
For i = 1 To .FoundFiles.Count
Range("A500").End(xlUp).Offset(1, 0).Value = .FoundFiles(i)
Next i
Else
End If
End With
End Sub
Thanks for your help
Still a beginner, ( not giving up though )..
The below code works fine, but could not make it list only the name of the found file(s).
Ideally the result should only be the name of the file, without the extension and path.
Private Sub listfiles()
Set pa = Application.FileSearch
With pa
.LookIn = "C:\Downloads\Bucsai"
.SearchSubFolders = True
.Filename = "*.pdf"
If .Execute(SortBy:=msoSortByFileName) = 1 Then
For i = 1 To .FoundFiles.Count
Range("A500").End(xlUp).Offset(1, 0).Value = .FoundFiles(i)
Next i
ElseIf .Execute(SortBy:=msoSortByFileName) > 1 Then
For i = 1 To .FoundFiles.Count
Range("A500").End(xlUp).Offset(1, 0).Value = .FoundFiles(i)
Next i
Else
End If
End With
End Sub
Thanks for your help