if File Exists function

  • Thread starter Thread starter Mike P
  • Start date Start date
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.
 
You will need to use the Scripting.FileSysytemObject to determine if a file
exist or not.
 
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
 
Back
Top