Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

startup macro to delete a file

Status
Not open for further replies.

sahmiele

Technical User
Sep 9, 2003
67
US
I would like to create a macro that runs each time I open Excel. I have a file called "order entry setup" in the XLStart folder. I want it to look at the date it was created, and if the current date is more than one month later, I want it to delete itself. Is this possible and if so, how? I want to make sure that my remote users are continually updating this file. Thanks in advance.
 
Haven't got your answer but a few suggestions.
To run a macro each time the file opens use the Workbook_Open event or Auto_Open

Check out to determine the file creation date

Have a look in the VBE help for the Kill Statement

Chris ;-)

Visit for great xl and xl/VBA help
 
I understand how to use the kill statement. The only problem is that I need the macro to go into the file that is going to be deleted and the kill statement will not delete a file that is already open. Once I close the file down, the macro quits running. I somehow need to have the startup macro create a new file, put the kill statement in a macro on that file, run the macro in the other file, which would close the original file and then execute the kill statement. I don't know if this makes sense or if it is even possible. Any thoughts would be greatly appreciated.
 
Have you tried to save the workbook in a temporary location, hopefully this will close the launched one ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top