How Do I Determine If File Exists Using VBA Excel 2007?

I am attempting to rewrite some code that was using FileSearch for Excel 2003 VBA. I'm attempting to call a function that should determine 1 or 0 and using an If statement I will execute some code or iterate to the next file.

I am not returning the correct result from my function.

My code:

 Dim MyDir As String, Fn As String
 Dim MyFile As String

   MyDir = "C:Test\"
   Fn = "" & "" & Examiner & " " & MnName & " " & Yr & ".xls"
   MyFile = MyDir & """" & Fn & """"

    If FileThere(MyFile) Then
    MsgBox yes

    Else
    MsgBox Not there

    End If

    '''''''''''''''''
    Function FileThere(FileName As String) As Boolean
         FileThere = (Dir(FileName) > "")
    End Function
5
задан Community 9 July 2018 в 19:34
поделиться