MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Deleting Excel files off the drive using code

Posted by Max on August 17, 2000 2:40 AM

Is there a way to delete files off the drives (using Macro)?

The reason being is that I have a programme that saves as certain Excel files.

Once the programme is run - the files are dormant and are no longer needed. -However if the programme is run again it may trip over as the same file names may be found.

So I need a Macro that will remove the files off the drive (So that I can attach it to the main programme - like a close down code).

Is this possible?


Posted by David on August 17, 0100 2:47 AM

How about checking if the file exists and if it is just overwrite it.

Posted by Ryan on August 17, 0100 8:57 AM


If you know the filename use this:

Sub DeleteFill

Kill "C:\MyDocs\Filename"

End Sub

This deletes it w/o putting it in the recycle bin so be careful.


Posted by Max on August 17, 0100 9:08 AM

Thanks Guys

Big thanks. ,