Need to replace file search code

troyedmonds

New Member
Joined
Jan 8, 2013
Messages
6
I have some code that uses filesearch and it does not work in 2007. Can anyone please tell me how to fix this code!!!!!

Private Sub btnBeginDateSearch_Click()
Dim FileExtension, ASCII_Space
Dim TempData
FileDirectory = "C:\Logansport\Turbidity\"
FileExtension = "*(wide).dbf"
ASCII_Space = " "
ListBox1.Clear
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Logansport\Turbidity"
.SearchSubFolders = False
CompleteFileName = MyYear + ASCII_Space + MyMonth + ASCII_Space + MyDay + ASCII_Space + FileExtension
.FileName = CompleteFileName
If .Execute() > 0 Then
If .Execute() = 1 Then
Dim Msg, Style, Title, Response
Dim Listbox1Value
CompleteFileName = .FoundFiles(1)
For i = .FoundFiles.Count To 1 Step -1
ListBox2.AddItem (.FoundFiles(i))
Next i
UpdateWorkbook2
ListBoxStatus
ElseIf .Execute() > 1 Then
CompleteFileName = .FoundFiles(1)
ListBox2.Visible = True
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
FoundFiles = .FoundFiles.Count
For i = .FoundFiles.Count To 1 Step -1
ListBox2.AddItem (.FoundFiles(i))
Next i
lblSearchByDate.Visible = True
If ListBox2.ListCount > 0 Then
End If

End If
Else
MsgBox "There were No Matching Files Found. Confine your search to the PREVIOUS THREE MyMonthS."
End If
End With

End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Application.FileSearch was removed starting in Excel 2007.

Take a look at the Dir command.
 
Upvote 0

Forum statistics

Threads
1,221,700
Messages
6,161,378
Members
451,700
Latest member
Eccymarge

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