Check if file exists before importing it

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I do this in visual basic? I tried FileExists Method:

Input_File = "W:\cnai\export\" & Tables!Table_Name & ".txt""

If FileExists(Input_File) Then


But it fails saying it doesn't recognize the function.
 
Ian said:
How do I do this in visual basic? I tried FileExists Method:

Input_File = "W:\cnai\export\" & Tables!Table_Name & ".txt""

If FileExists(Input_File) Then


But it fails saying it doesn't recognize the function.


Use the Dir function
 
Just to expand on Marsh's answer, there's no built-in FileExists function in
VBA.

You could write your own, or you can simply use:

If Len(Dir(Input_File)) > 0 Then
 
Back
Top