Delete file after import

  • Thread starter Thread starter Mike Kaendera
  • Start date Start date
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.
 
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


.
 
Back
Top