Code doesn't work (from Dev's site) 
Author Message
 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

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
        .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

Sat, 29 Jun 2002 03:00:00 GMT  
 Code doesn't work (from Dev's site)
Sir: A constant with a "mso" prefix likely belongs to the Microsoft Office
Object Library. Have you set a reference to that? Also, this routine calls
fGetFileName(), which I imagine to be another user-defined function. Have
you defined this function?

Not an expert. Just FWIW.

...>        .FileType = msoFileTypeAllFiles    'ERROR HERE
...>                strTmp = fGetFileName(varItm)

Sat, 29 Jun 2002 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Problem with Window Resizing code from Dev's site

2. Ken Getz's GetOpenFile as Posted on Dev's site

3. Dev Ashish's API, SysTray icon doesn't dissappear as needed

4. fRefreshLinks Doesn't work if path doesn't exist

5. old code - new browser - code doesn't work

6. Shortcut keys won't work in VB Dev't Environment

7. 'Next Comment' doesn't work

8. closing access from code doesn't work, see further down

9. Code converted from macro doesn't work

10. HELP! Code doesn't work any more

11. Code doesn't work, why?

12. Converting to Access 2002 Code doesn't work


Powered by phpBB® Forum Software