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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete a File Using VBA 1

Status
Not open for further replies.

cranebill

IS-IT--Management
Jan 4, 2002
1,113
US
If i wanted to delete a file using VBA and i know the path,filename, and extension, how would i go about doing this?

Bill
 
Solution:

Kill "complete path"

You can also cantonate to get the filename in case of variables.

Thanx Foolio

Bill
 
My FileSystemObject doesn't have the 'Kill' method stated above. I've never heard it associated with the FileSystemObject. You need to add a reference to the 'Microsoft Scripting Runtime' to use the object.

Dim fso As FileSystemObject
Call fso.DeleteFile("C:\Groups\MyFilename.xls")

The FileSystemObject is very rich with file handling functionality, including other methods such as BuildPath, CopyFile, CopyFolder, CreateTextFile, CreateFolder and about 12 others.

-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top