Transfer Text Macro - How to stop macro if file isn't there

D

DBM

Hello -

I have a macro that imports a text file, then runs multiple queries to
move/update tables. Unfortunately, the file name was named incorrectly the
last time I ran the macro therefore based upon my queries it blew out some
data. Fortunately, I have back-ups and could fix the error.

Trying to prevent this from occurring in the future, I am having trouble
writing a new macro line to stop the macro if the file for the Transfer Text
line doesn't exist.
Is this an easy fix?

Any guidance is much appreciated!
Best,
Darren
 
S

Steve Schapel

Darren,

Add a StopMacro action at the beginning of your macro, and use the
equivalent of the following as the Condition...
Len(Dir("C:\YourFolder\YourFile.txt"))=0
 

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