I copied this code from The Access Web and am trying to run it but I seem to be stumbling on the line If .Execute >0 Then It never returns a value for .Execute > 0. If I change it to > = 0 then it runs till the next line then bombs. Anyone use this or something like it. I’m trying to create a work around for the Windows Explorer Find Dialog Box. Thanks
Paul
Function fReturnFilePath(strFilename As String, _
strDrive As String) As String
Dim varItm As Variant
Dim strFiles As String
Dim strTmp As String
If InStr(strFilename, “.”) = 0 Then
MsgBox “Sorry!! Need the complete name”, vbCritical
Exit Function
End If
strFiles = “”
With Application.FileSearch
.NewSearch
.LookIn = strDrive
.SearchSubFolders = True
.FileName = strFilename
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
If .Execute > 0 Then
For Each varItm In .FoundFiles
strTmp = fGetFileName(varItm)
If strFilename = strTmp Then
fReturnFilePath = varItm
Exit Function
End If
Next varItm
End If
End With
End Function
Private Function fGetFileName(strFullPath) As String
Dim intPos As Integer, intLen As Integer
intLen = Len(strFullPath)
If intLen Then
For intPos = intLen To 1 Step -1
‘Find the last
If Mid$(strFullPath, intPos, 1) = “” Then
fGetFileName = Mid$(strFullPath, intPos + 1)
Exit Function
End If
Next intPos
End If
End Function