ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting Run-time error '445' (https://www.excelbanter.com/excel-programming/443427-getting-run-time-error-445-a.html)

Hari[_5_]

Getting Run-time error '445'
 
Hi,

I am looking to get the list of excel files in a folder through VBA.
By browsing the net i found this

Sub Search_files()
Dim FileS As FileSearch
Dim F As Variant
Dim x As Integer
Set FileS = Application.FileSearch
With FileS
.NewSearch
.Filename = InputBox("Insert file name")
.LookIn = InputBox("Insert the path")
.SearchSubFolders = True
.Execute
End With
x = 1
For Each F In Application.FileSearch.FoundFiles
Cells(x, 1) = F
x = x + 1
Next F
End Sub

When the cursor goes to "Set FileS = Application.FileSearch" it says
the OBJECT DOESN'T SUPPORT THIS ACTION"

Kindly provide solution

Thanks'
Hari

Jim Cone[_2_]

Getting Run-time error '445'
 

FileSearch was removed from xl2007. Use the Dir function.
--
Jim Cone
Portland, Oregon USA
List Files add-in: http://tinyurl.com/ListFiles



"Hari"
wrote in message
Hi,
I am looking to get the list of excel files in a folder through VBA.
By browsing the net i found this

Sub Search_files()
Dim FileS As FileSearch
Dim F As Variant
Dim x As Integer
Set FileS = Application.FileSearch
With FileS
.NewSearch
.Filename = InputBox("Insert file name")
.LookIn = InputBox("Insert the path")
.SearchSubFolders = True
.Execute
End With
x = 1
For Each F In Application.FileSearch.FoundFiles
Cells(x, 1) = F
x = x + 1
Next F
End Sub

When the cursor goes to "Set FileS = Application.FileSearch" it says
the OBJECT DOESN'T SUPPORT THIS ACTION"

Kindly provide solution
Thanks'
Hari


All times are GMT +1. The time now is 11:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com