Missing file?

karcher

New member
Local time
Today, 20:20
Joined
Jul 27, 2001
Messages
5
Anyone know a way I can look for a file and then run code *only* if that particular file exists?

Right now I'm creating a .txt file (using vba) and attaching to an email message in MS Outlook. When you click on the "send mail" button, it prompts the user to enter an ID number and then emails the corresponding .txt file.

My problem comes when the user cancels the prompt and doesn't enter an ID number. They get an error message saying that the file can't be found. I know it can't be found because the "cancel" has stopped it from being created, but how do I get vba to understand that?

It has to check and see if the file's there (and stop what it's doing if it can't find it). I checked the help and found something called FileSearch, but I couldn't get it to work.

Any ideas would be greatly appreciated!

Thanks,
K
 
Use the DIR function.
If it returns a zero length string {""} then the file doesn't exist and you can then skip the problem code.
 

Users who are viewing this thread

Back
Top Bottom