ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete a workbook (https://www.excelbanter.com/excel-programming/332438-delete-workbook.html)

sharman

Delete a workbook
 
Is it possible to delete a workbook through a macro? Thanks in advance

Chip Pearson

Delete a workbook
 
A workbook is the same as the file, so you'd first close the
workbook, then Kill the file. E.g.,

Workbooks("TheBook.xls").Close SaveChanges:=False
Kill "TheBook.xls"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"sharman" wrote in message
...
Is it possible to delete a workbook through a macro? Thanks in
advance




sharman

Delete a workbook
 
Thanks a lot for the quick response. Please let me know if there is a way of

a. renaming the files
b. saving the files with a different name in a particular folder

by using a macro. Thanks again.


"Chip Pearson" wrote:

A workbook is the same as the file, so you'd first close the
workbook, then Kill the file. E.g.,

Workbooks("TheBook.xls").Close SaveChanges:=False
Kill "TheBook.xls"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"sharman" wrote in message
...
Is it possible to delete a workbook through a macro? Thanks in
advance





Dave Peterson[_5_]

Delete a workbook
 
a. Look up Name in VBA's help
b. Look up SaveAs in VBA's help.



sharman wrote:

Thanks a lot for the quick response. Please let me know if there is a way of

a. renaming the files
b. saving the files with a different name in a particular folder

by using a macro. Thanks again.

"Chip Pearson" wrote:

A workbook is the same as the file, so you'd first close the
workbook, then Kill the file. E.g.,

Workbooks("TheBook.xls").Close SaveChanges:=False
Kill "TheBook.xls"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"sharman" wrote in message
...
Is it possible to delete a workbook through a macro? Thanks in
advance





--

Dave Peterson

sharman

Delete a workbook
 
Thanks for the reply. I looked up as per your suggestion and it helped. I
want to know if it's possible to activate/close an open workbook by using a
part name alongwith with a wild character? Like if the workbook name is
"OLD_6_10" and I want to activate it by just using "OLD*". I tried to use
but I get an error message. Thanks in advance.

"Dave Peterson" wrote:

a. Look up Name in VBA's help
b. Look up SaveAs in VBA's help.



sharman wrote:

Thanks a lot for the quick response. Please let me know if there is a way of

a. renaming the files
b. saving the files with a different name in a particular folder

by using a macro. Thanks again.

"Chip Pearson" wrote:

A workbook is the same as the file, so you'd first close the
workbook, then Kill the file. E.g.,

Workbooks("TheBook.xls").Close SaveChanges:=False
Kill "TheBook.xls"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"sharman" wrote in message
...
Is it possible to delete a workbook through a macro? Thanks in
advance




--

Dave Peterson



All times are GMT +1. The time now is 10:29 AM.

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