Saving without VBA code

C

Carl Rapson

I have a workbook that has some VBA code in the ThisWorkbook module to
define a toolbar button. This button uses VBA code in another module to save
a set of ranges to a new spreadsheet file. I accomplish this by creating a
new workbook, copying each range (each is on a separate worksheet), then
saving the new workbook with a new name. Unfortunately, the VBA code in
ThisWorkbook is also copied to the new workbook, so when the new spreadsheet
file is opened, it also has the toolbar button. Is there any way to do this
without also copying the VBA code from ThisWorkbook? Or, is there a way to
remove that code from the new file?

Thanks for any information,

Carl Rapson
 
D

Dave Peterson

Chip Pearson has some techniques to delete code, but before you do this, how is
the code getting from the masterworkbook to the copy?

I've never seen code go from ThisWorkbook in one project to another Thisworkbook
in a new project when you create a new workbook.

dim wkbk as workbook
set wkbk = workbooks.add(1)

creates a new workbook w/o code in ThisWorkbook.

oh, here's that link to Chip's site:
http://www.cpearson.com/excel/vbe.htm
 
Top