ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy & Delete (https://www.excelbanter.com/excel-programming/327906-re-copy-delete.html)

phil

Copy & Delete
 
Hi Rob,

Thanks for the quick reply, I have tired this and I keep getting the debug
error on the keywords (set newbook) and ideas why this would be, would it be
of any help if I posted all of my code?

Thanks Phil

"Rob" wrote:

try:

Thisworkbook.savecopyas "NewFileName.xls"
Set NewBook=workbooks("NewFileName.xls").open
with newbook
application.displayalerts=false
.sheets("sheetName").delete
application.displayalerts=true
end with
'then your code for e-mailing etc



"Phil" wrote:

Hi,

I have a selection of code that currently makes a copy of the exsisting
workbook and then zips and emails that copy using Outlook, I know this might
sound hopeful but is it at all possible to delete a worksheet out of the copy
before it gets zipped and emailed.

Thanks
Phil


Rob

Copy & Delete
 
you need to declare the variable. Also "NewFileName.xls" should be the full
path where you are saving the workbook.

dim NewBook as workbook


Thisworkbook.savecopyas "NewFileName.xls"
Set NewBook=workbooks("NewFileName.xls").open
with newbook
application.displayalerts=false
.sheets("sheetName").delete
application.displayalerts=true
end with
'then your code for e-mailing etc




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

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