ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   delete a file in code (https://www.excelbanter.com/excel-programming/376618-delete-file-code.html)

Aidan

delete a file in code
 
How to delete a file in code? I dont want to be asked if i wanted or not to
do it

NickHK

delete a file in code
 
Look up "Kill" in the Help.

NickHK

"aidan" wrote in message
...
How to delete a file in code? I dont want to be asked if i wanted or not

to
do it




Corey

delete a file in code
 
Try:


sub DeleteFile()
Application.DisplayAlerts =False
If Dir("C:\my documents\File Name to be Deleted.xls") < "" Then _
Kill "C:\my documents\File Name to be Deleted.xls"
Application.DisplayAlerts = True
end sub




Regards

Corey



Chip Pearson

delete a file in code
 
If you want to permanently and completely delete the file, use the Kill
statement. Note that Kill does not send the file to the Recycle Bin. The
file is gone forever. If you want to delete the file, but put it in to the
Recycle Bin, use the code on http://www.cpearson.com/excel/recycle.htm .


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)


"aidan" wrote in message
...
How to delete a file in code? I dont want to be asked if i wanted or not
to
do it





All times are GMT +1. The time now is 05:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com