if File Exists function

M

Mike P

I wish to validate that a file exists before I start the import. This is to
be done programaticlly since I am importing many files. Is there a simple
IsFile() function that I can write or use? I can't seem to locate one.

My code is something like this:
' * * *
Do while ctr <= numberOfFiles
strImportFile = strFilePath & strFileName
' i need the logic for the function below
If fileExissts( strImportFile ) Then
processFile
Endif
' move onto next file to process
Loop

Thanks,
Mike P.
 
J

Jim Pan

You will need to use the Scripting.FileSysytemObject to determine if a file
exist or not.
 
D

Dirk Goldgar

Jim Pan said:
You will need to use the Scripting.FileSysytemObject to determine if a
file
exist or not.


Why add the overhead of the Scripting library and the FileSystemObject when
you can use the built-in Dir() function for this?

If Len(Dir(strImportFile)) > 0 Then
' the file exists
Else
' it doesn't
End If
 

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