File Search Macro error

megha

New Member
Joined
May 15, 2009
Messages
46
I have very old written macro to pull file names from one particular folder. It was working great like a magic. Today I am getting error message "Run time error 445: Object doesn't support this action" when I tried to run it. I double check the path and its correct. Not sure what is going wrong. Can someone please help?

Here is the code I am using:

BTW, i have a "completed checklist" folder where everyone housekeeping reports are saving on monthy basis. so, I use Month and year in cell E4 (i.e. Mar_2014) to run this script.

Code:
Private Sub CommandButton1_Click()
Dim fs As FileSearch, ws As Worksheet, i As Long
    Set fs = Application.FileSearch
    With fs
        .SearchSubFolders = False ' set to true if you want sub-folders included
        .FileType = msoFileTypeAllFiles 'can modify to just Excel files eg with msoFileTypeExcelWorkbooks
        .LookIn = "[URL="file://sptd.sabert.net/sites/op/olt/Production"]\\sptd.sabert.net/sites/op/olt/Production[/URL] Supervisors/HouseKeeping/Completed_Checklist\" & Range("E4").Value 'modify this to where you want to serach
        If .Execute > 0 Then
            Set ws = Worksheets.Add
            For i = 1 To .FoundFiles.Count
                ws.Cells(i, 1) = Mid$(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1)
            Next
        Else
            MsgBox "No files found"
        End If
    End With
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Did you shut down and restart to eliminate a PC issue
 
Upvote 0
Thank you so much for this. I looked at the link you have sent me. Yes, I have the same issue. I had the code for 2003 and now we are using 2010. I am little lost here not sure how to edit my code. Can you please help?
 
Upvote 0
post the code here between code tags, oops it is posted above
 
Last edited:
Upvote 0
Code:
Private Sub CommandButton1_Click()
Dim fs As FileSearch, ws As Worksheet, i As Long
    Set fs = Application.FileSearch
    With fs
        .SearchSubFolders = False ' set to true if you want sub-folders included
        .FileType = msoFileTypeAllFiles 'can modify to just Excel files eg with msoFileTypeExcelWorkbooks
        .LookIn = "[URL="file://sptd.sabert.net/sites/op/olt/Production"][COLOR=#49644e]\\sptd.sabert.net/sites/op/olt/Production[/COLOR][/URL] Supervisors/HouseKeeping/Completed_Checklist\" & Range("E4").Value 'modify this to where you want to serach
        If .Execute > 0 Then
            Set ws = Worksheets.Add
            For i = 1 To .FoundFiles.Count
                ws.Cells(i, 1) = Mid$(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1)
            Next
        Else
            MsgBox "No files found"
        End If
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,783
Messages
6,132,692
Members
449,751
Latest member
Svitlana D

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