2007 Fix for Application.FileSearch

aymanm

Board Regular
Joined
Sep 10, 2007
Messages
56
Hello:

Is there a fix for this in Excel 2007?

Run-time error '445': Object doesn't support this action

Sub BatchProcess()
Dim FS As FileSearch
Dim FilePath As String, FileSpec As String
Dim i As Integer

' Specify path and file spec
FilePath = ThisWorkbook.Path & "\"
FileSpec = "text??.txt"

' Create a FileSearch object
Set FS = Application.FileSearch
With FS
.LookIn = FilePath
.FileName = FileSpec
.Execute
' Exit if no files are found
If .FoundFiles.Count = 0 Then
MsgBox "No files were found"
Exit Sub
End If
End With

' Loop through the files and process them
For i = 1 To FS.FoundFiles.Count
Call ProcessFiles(FS.FoundFiles(i))
Next i
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Something like this :-
Code:
    Dim CheckFile As String
    Dim MyPath As String
    '--------------------------------------------
    MyPath = "C:\"
    CheckFile = Dir(MyPath & "*.xls")   ' filter .xls files
    '- no files
    If CheckFile = "" Then
        MsgBox ("No .xls files in " & MyPath)
    End If
    '- loop through files in folder
    Do While CheckFile <> ""
        rsp = MsgBox("Do you wish to open " & CheckFile & " ?", vbYesNoCancel)
        If rsp = vbCancel Then End
        If rsp = vbYes Then
            Workbooks.Open Filename:=MyPath & CheckFile
        End If
        CheckFile = Dir    ' Get next file
    Loop
 
Upvote 0
In addition to the suggestion you've already received, you might also want to check the FileSystemObject. Search msdn.microsoft.com for more.

Hello:

Is there a fix for this in Excel 2007?

Run-time error '445': Object doesn't support this action

{snip}
 
Upvote 0

Forum statistics

Threads
1,213,486
Messages
6,113,932
Members
448,533
Latest member
thietbibeboiwasaco

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