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

Deleting an xls file using VBA

Status
Not open for further replies.

lj50v

Programmer
Sep 21, 2008
6
AU
As part of a small application where I open a number of different files and extract some data, I then save the newly created sheet.

As the VBA code is static in this sense, I need to be able to delete the newly created file.

If the processed file is opened using -
Workbooks.Open Filename:=FileToOpen

How do/can I delete a file when I no longer need it, and is it possible to NOT be prompted as to whether I'm sure I want to do this? !!

Many thanx in advance
 
Hi lj50v,

If you haven't saved the newly created workbook, all you need to do is to close it without saving - there is no file to delete.


Cheers
[MS MVP - Word]
 
Thanks for that, but as part of the process I do save the file as I need to keep the new information. As that is the case I can always save it in a different location, but it doesn't stop the fact that I would still like to be able to delete a/the file on the fly.

Seeing that Activate, Close, SaveAs are all there as part of Workbooks or ActiveWorkbook, what do we do to Delete?

Many thanx
 
Kill "\path\to\file.ext"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top