Consulting

Results 1 to 12 of 12

Thread: FileSearch Macro error

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Oct 2009
    Posts
    69
    Location

    FileSearch Macro error

    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.

    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 = "\\sptd.sabert.net/sites/op/olt/Production 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
    Last edited by megha; 04-04-2014 at 10:22 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •