98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » excel 2003 visual basic intermediate course - Deleting a file
excel 2003 visual basic intermediate course - Deleting a file
Resolved · Low Priority · Version Standard
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
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Quick Absolute Cell ReferencesWhen entering cell references in a formula you probably click the cell, or you may type in the cell reference. If you require any of the 4 variations, press the F4 key now before you press Enter to toggle around the relative and absolute entries ($signs). |