ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Copy workbook, don't copy macro (https://www.excelbanter.com/excel-discussion-misc-queries/191134-copy-workbook-dont-copy-macro.html)

CongroGrey

Copy workbook, don't copy macro
 
Is it possible to copy a workbook but not the macro?

Backround - I have created a workbook which receives transferspreadsheet
data from Access. I have an Excel macro which formats the sheet, then
deletes the transferspreadsheet sheet. I want the user to be able to save
this report with the current date, but not copy the macro to the new sheet.

Is this possible?

Kevin B

Copy workbook, don't copy macro
 
Add code to your macro to move the formatted sheet into a new workbook,
change the MyNewWorkbook.xls to the name you want the new file to have and
the FormattedSheet.xls name to the name of the workbook that contains the
macro:

Application.Workbooks.Add
ActiveWorkbook.SaveAs "MyNewWorkbook.xls"
Application.Workbooks("FormattedSheet.xls").Sheets (1).Activate
Sheets(1).Activate
ActiveSheet.Move Befo=Workbooks("MyNewWorkbook.xls").Sheets(1)

--
Kevin Backmann


"CongroGrey" wrote:

Is it possible to copy a workbook but not the macro?

Backround - I have created a workbook which receives transferspreadsheet
data from Access. I have an Excel macro which formats the sheet, then
deletes the transferspreadsheet sheet. I want the user to be able to save
this report with the current date, but not copy the macro to the new sheet.

Is this possible?



All times are GMT +1. The time now is 01:27 AM.

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