Maybe something like this?
Sub FileSearch()
myDrive = Range("C1")
ChDir myDrive
'set current directory as the one to search
CurrentDirectory = myDrive
'look in current directory and count the number of jpg files
With Application.FileSearch
.LookIn = CurrentDirectory
.Filename = "*.jpg"
.SearchSubFolders = False
If .Execute() > 0 Then
MessageText = "There were " & .FoundFiles.Count & " file(s) found."
Choice = MsgBox(MessageText, vbOKCancel)
If Choice = vbCancel Then GoTo leave
For i = 1 To .FoundFiles.Count
'call your subroutine here!
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found.", vbCritical
End If
leave:
End Sub
Bookmarks