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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top