4 replies
by graemeh
Apologies if this turns out to be a repost; having a few problems here!
This is one way to approach it:
Sub FindFile()
Dim sFileName As String
Dim x As Integer
Dim sFile As String
sFileName = "test data.xls"
WithApplication.FileSearch
.Filename = sFileName
.LookIn = "C:\"
.SearchSubFolders = True
x = .Execute
If x = 1 Then
'found it
sFile = .FoundFiles(1)
ElseIf x > 1 Then 'more than one found; FoundFiles contains all the pathnames
ElseIf x = 0 Then
'not found
End If
End With
End Sub
You need to modify filenames/drives as needed or change to a function.
HTH
graeme
by hurdk
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending