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