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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,484
Application.FileSearch Is NOT supported in xl2007. Could that be your problem?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,109
Messages
5,857,443
Members
431,879
Latest member
KiwDaWabbit

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
Top