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 ?
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 ?