Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2010
    Posts
    2

    Unanswered: Application.Filesearch in Access 2007

    Hi,

    I am trying to update a number of databases written in Access 2003 so that they will function in Access 2007. The problem I'm having is when it comes to trying to re-write VB that uses the Application.Filesearch functionality that has been removed from Office 2007.

    I have found some very helpful information and resources regarding use of the Dir and FileSystemObject, but unfortunately I am not the database author and am a complete VB novice. I am therefore really struggling to successfully convert the Filesearch functionality using Dir.
    An example of the type of code I am trying to convert is listed below, any help with this would be greatly appreciated!

    Code:
    Function File_Exists(Filename As String)
    
    File_Exists = False
    
    With Application.FileSearch
        .NewSearch
        .LookIn = DirPart(Filename)
        .SearchSubFolders = False
        .Filename = FilePart(Filename)
        .MatchTextExactly = True
    '    .FileType = msoFileTypeAllFiles
        File_Exists = .Execute() <> 0
    End With
    
    End Function

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Here is an acceptable replacement, though it will not replace FileSearch
    in any circumstances, it will work here:
    Code:
    Function File_Exists(Filename As String) As Boolean
        If Len(Dir(Filename)) > 0 Then File_Exists = True
    End Function
    Have a nice day!

  3. #3
    Join Date
    Sep 2010
    Posts
    2
    Thank you so much, that appears to replace the code nicely!

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •