title: How Do I Determine If File Exists Using VBA Excel 2007?
body: <p>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 <code>If</code> statement I will execute some code or iterate to the next file.  </p>
  
  <p>I am not returning the correct result from my function. </p>
  
  <p>My code:</p>
  
  <pre><code> Dim MyDir As String, Fn As String
   Dim MyFile As String
  
     MyDir = "C:Test\"
     Fn = "" &amp; "" &amp; Examiner &amp; " " &amp; MnName &amp; " " &amp; Yr &amp; ".xls"
     MyFile = MyDir &amp; """" &amp; Fn &amp; """"
  
      If FileThere(MyFile) Then
      MsgBox yes
  
      Else
      MsgBox Not there
  
      End If
  
      '''''''''''''''''
      Function FileThere(FileName As String) As Boolean
           FileThere = (Dir(FileName) &gt; "")
      End Function
  </code></pre>