ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to delete a file using VBA (https://www.excelbanter.com/excel-programming/301511-how-delete-file-using-vba.html)

Graham Standring

How to delete a file using VBA
 
I am sure this must be a really easy process but I have searched and
searched for an answer without success.

I need to include a command in an Excel macro which will delete a file.
The name of the file will vary each time the macro runs but the path,
filename and extension are held in a cell in the spreadsheet. Note that
the file that I want to delete is not the Excel file which is running
the macro and it is not an open file. (It is actually a .txt file in a
different directory.)

Can anybody tell me what the code is?

I am using Office XP on Windows XP and also on Windows 2000.

Thanks in advance.

Graham Standring
University of Sunderland
UK.


JWolf

How to delete a file using VBA
 
See the Kill Statement in VBA help.

Graham Standring wrote:
I am sure this must be a really easy process but I have searched and
searched for an answer without success.

I need to include a command in an Excel macro which will delete a file.
The name of the file will vary each time the macro runs but the path,
filename and extension are held in a cell in the spreadsheet. Note that
the file that I want to delete is not the Excel file which is running
the macro and it is not an open file. (It is actually a .txt file in a
different directory.)

Can anybody tell me what the code is?

I am using Office XP on Windows XP and also on Windows 2000.

Thanks in advance.

Graham Standring
University of Sunderland
UK.



All times are GMT +1. The time now is 01:26 PM.

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