-
Check if file exists
Is there a good example of how to check if the file with a prticular name already exists.
Also it would be nice to find a good mechanism that automaticaly create a versioned file name like myfile_001 or myfile_002 if myfile and myfile_001 already exist.
Thank you!
-
Re: Check if file exists
Here is a fairly simple method to detect if a file exists or not..
Dim fso
set fso = CreateObject("scripting.FileSystemObject")
If Not fso.FileExists("test.txt") then
msgbox "This file does not exist!"
End if
-
Re: Check if file exists
An even simple would be:
if Dir(MyFile.txt)<>"" then... 'file exists!
----------
The @host is everywhere!
----------
-
Re: Check if file exists
this is actualy better
FileName = Dir(path & SearchStr, vbNormal Or vbHidden Or vbSystem _
Or vbReadOnly)
thank you.