excel 2003 visual basic intermediate course - deleting file

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum 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

resolvedResolved · 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

Edited on Mon 26 Nov 2007, 14:44

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

RE: deleting a file

thanks for this carlos.. another question answered!!
sam

 

Training courses

 

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Quick Absolute Cell References

When 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).

Note that the F4 key outside of editing a formula is the Repeat key to repeat a previous action.

View all Excel hints and tips


Server loaded in 0.08 secs.