
Code doesn't work (from Dev's site)
I can't seem to get the code for finding a file to work.
The code is from Dev's site under API "Search for a file" :
At the line marked below I get run time error 5; "Invalid procedure or
argument.".
The Access 8.0 Object Library is available.
'**code begin***
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 'ERROR HERE
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
'**code end***
---
Best regards
Morten Snedker
www.access-dk.mobilixnet.dk