Check if file exists before importing it

I

Ian

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

Marshall Barton

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
 
D

Douglas J. Steele

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
 
Top