Macro - Can a macro be stopped based on user input?

A

Alison

Hi Martin,

I have a similar problem - I want to say if the file
exists replace it but dont know how - I have a macro that
deletes a file then imports data to replace it which
works unless the file to import doesnt exist then it
crashes and the next time I run it it crashes because the
file I want to delete doesnt exist. If you find out how
to code (If a file exists then....) let me know. I am
posting the question myself so will let you know if I
find out myself!!

good luck

Alison
 
K

Ken Snell

I'm not sure how your macro is deleting a file, but taking that at face
value, you can put an If...Then statement as the condition of the macro step
that is doing the deletion:

Condition: Dir("C:\FolderName\FileName.txt")

If the above condition is true, it will run that deletion step (whatever it
is that you have).
 

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