ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting a workbook from Disk (https://www.excelbanter.com/excel-programming/346817-deleting-workbook-disk.html)

Peter Rooney

Deleting a workbook from Disk
 
Good morning, all,

Nice easy one for you all.

Is it possible to delete a workbook from a disk using VBA?
I tried to record myself doing it, with File Open, right clicking a
workbook, then clicking "Delete", but all I got was a CHDir Command.

Thanks in advance

pete



Andrew Taylor

Deleting a workbook from Disk
 
You can use the Kill statement to do this:

Kill "C:\myfolder\myfile.xls"

This will throw an error if the file doesn't exist, or if it can't be
deleted
for some reason (e.g. read-only or in use), so you might want to put
in some error-handling.

Andrew Taylor


Peter Rooney wrote:
Good morning, all,

Nice easy one for you all.

Is it possible to delete a workbook from a disk using VBA?
I tried to record myself doing it, with File Open, right clicking a
workbook, then clicking "Delete", but all I got was a CHDir Command.

Thanks in advance

pete



Peter Rooney

Deleting a workbook from Disk
 
Andrew,

Just the job.

Thank you!

Pete



"Andrew Taylor" wrote:

You can use the Kill statement to do this:

Kill "C:\myfolder\myfile.xls"

This will throw an error if the file doesn't exist, or if it can't be
deleted
for some reason (e.g. read-only or in use), so you might want to put
in some error-handling.

Andrew Taylor


Peter Rooney wrote:
Good morning, all,

Nice easy one for you all.

Is it possible to delete a workbook from a disk using VBA?
I tried to record myself doing it, with File Open, right clicking a
workbook, then clicking "Delete", but all I got was a CHDir Command.

Thanks in advance

pete




Christmas May[_2_]

Deleting a workbook from Disk
 


"Peter Rooney" wrote:

Good morning, all,

Nice easy one for you all.

Is it possible to delete a workbook from a disk using VBA?
I tried to record myself doing it, with File Open, right clicking a
workbook, then clicking "Delete", but all I got was a CHDir Command.

Thanks in advance

pete




All times are GMT +1. The time now is 06:15 AM.

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