Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ckeck to see if a file exists

Status
Not open for further replies.

chiefvj

Technical User
Feb 4, 2005
73
US
i have search the forum looking for a fileexit routine. Any ideas. thx
 
You can use the Dir() function. If the file exits, it will return the file name. If it does not exist, it will return zero-length.

Code:
Dir("c:\[i][path to the file][/i]\filename.xxx)
 
Hi,
You can also use the FileSystemObject Object
Add a reference to the Microsoft Scripting Runtime object by choosing Tools > References select Microsoft Scripting Runtime and click OK
Add
Dim FSys As New FileSystemObject
If Sys.FileExists("C:\[Path to file]\[Filename].exe) Then
Do event
else

End if
This method can be faster.
you can copy files and folders move them or delete them
Look up scripting objects

Hope this help

vvrt
 
I want to run an external mdb file. what i did was to set an error check and if the event was unable to find the file an error would be generated and a message would pop up and the code would bypass any attempt to run the application. Thanks for the routine. Iwill give it a try. thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top