Error with Application.FileSearch

MR Campbell

Board Regular
Joined
Aug 2, 2002
Messages
113
I have the following code which works fine on my desktop computer but not on my laptop ... I am very confused why I am getting an error with the Application.FileSearch line of code.

I get a Run time error '445' ....
Object doesn't support this action


Private Sub DeleteFiles()
'This routine will delete all the .xls files in the FormSent folder and in the
'DataFromSchools folder

Dim KillPath As String 'directory path for the FormsSent folder
Dim i As Integer 'counter for all files found in the folder


'find all .xls files in this folder and Delete them
KillPath = ThisWorkbook.Path & "\FormsSent\" 'FormsSent folder

With Application.FileSearch
.LookIn = KillPath
.FileName = "*.xls"
.Execute
For i = 1 To .FoundFiles.Count
Kill .FoundFiles(i)
Next i
End With

'find all .xls files in the DataFromSchools folder and Delete them
KillPath = ThisWorkbook.Path & "\DataFromSchools\" 'DataFromSchools folder
With Application.FileSearch
.LookIn = KillPath
.FileName = "*.xls"
.Execute
For i = 1 To .FoundFiles.Count
Kill .FoundFiles(i)
Next i
End With

End Sub


Does anyone know why this might be happening ?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Application.FileSearch Is NOT supported in xl2007. Could that be your problem?
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top