Delete file after import

M

Mike Kaendera

I want to know how do you set up a macro to delete a file
after it has imported it. I have a macro that imports data
from a text file everyday. I want my the macro to only
import data once. I created a button that when you press
runs the macro. Right now if you press the button five
times it will import the data five times.I want it to
delete the data after it imports it.
 
M

Mikek

Thank you so much
-----Original Message-----
Hi,

I don't know a way to do this direct in a macro, but you could use VBA
instead and start it with RunCode in a macro:

Function FileDelete()
On Error GoTo Err1
ChDir ("C:\Temp\") 'changes to specified directory
Kill "YourFile.txt" 'deletes the file, you can use the
placeholders * or ? as well
Exit Function

Err1:
MsgBox "Directory doesn't exist."
End Function

Regards,
Bernd


.
 

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