Samantha has attended:
Excel VBA Intro Intermediate course
Deleting a file
can you please tell me how i can delete a file from within excel vba?
the file is a .csv file or a .cap file (this is just a file with a .cap extension and is in effect a text file). After i do all the formatting on the file and paste it into another worksheet, i need to then clear down this file by deleting it.
can anyone please tell me how?
thanks
sam
RE: deleting a file
Hi Samantha
To delete a file from the system you need to know the name of the file to be deleted. then you instruct the system to Kill the file.
NB This permanently deletes the file from the hard drive. It doesn't put it in the Recycle bin.
The code is as follows as a example
Sub DeleteAFile()
Dim WbString As String
WbString = "C:\Documents and Settings\User6\My Documents\My Sheets.csv" 'The path of the file to be deleted
Kill WbString
End Sub
Hope this helps
Carlos