Why Application.FileSearch doesn't work?

grautu

New Member
Joined
Sep 26, 2004
Messages
38
The following code fragment
Code:
With Application.FileSearch
   .LookIn = sample_folder
   .
   .
   .
End With
may be useful when inspecting the content of sample_folder. I did successfully use that code pattern many times in the past (under Office 2003) but now it fails to work (under Office 2007). Here is the error message which I get:
Code:
Run-time error 445
Object doesn't support this action
Indeed, the Application.FileSearch property is not supported, but I can't figure why. Once again, this behaviour appeared after replacing MS Office 2003 with MS Office 2007.
The following items are checked under Tools -> References in my VBA setting:
1. Visual Basic For Application
2. Microsoft Excel 12.0 Object Library
3. OLE Animation
4. Microsoft Office 12.0 Object Library
Can anybody please explain me why Application.FileSearch property fails to work?
Thanks a lot in advance!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Here's a function I use in 2007 in replacement for Fileserach:

Code:
Sub testit() 
    myvar = FileList("C:\Test3") 
    If TypeName(myvar) <> "Boolean" Then 
        For i = LBound(myvar) To UBound(myvar) 
            Debug.Print myvar(i) 
        Next 
    Else 
         MsgBox "No files found" 
    End If 
End Sub 
 
 Function FileList(fldr As String, Optional fltr As String = "*.*") As Variant 
    Dim sTemp As String, sHldr As String 
    If Right$(fldr, 1) <> "\" Then fldr = fldr & "\" 
    sTemp = Dir(fldr & fltr) 
    If sTemp = "" Then 
        FileList = False 
        Exit Function 
    End If 
    Do 
        sHldr = Dir 
        If sHldr = "" Then Exit Do 
        sTemp = sTemp & "|" & sHldr 
     Loop 
    FileList = Split(sTemp, "|") 
End Function
 
Upvote 0
Thanks a lot!
Anyway it's hardly understanding why to remove FileSearch; just think about how meandring now is to replace the recursive search in the absence of FileSearch.
 
Upvote 0

Forum statistics

Threads
1,215,886
Messages
6,127,575
Members
449,385
Latest member
KMGLarson

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