ThisWorkBook.SaveCopyAs minus the VB Code

shanep

New Member
Joined
Mar 18, 2009
Messages
32
Hi

Is it possible to us .SaveCopyAs to save a copy of an existing workbook but in doing so remove all the VB in the saved copy of the workbook?

The reason I ask is that I have a workbook which I need to save a copy of, then open and delete most of the sheets. However, the workbook from which the copy is being created contains code in the workbook.open event and so when I open the copy to delete the sheets (which I want to occur without user intervention) the workbook.open code fires up (and prompts the user for input - which the code is designed to do) ...

Thanks
Shane
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi Andrew, thanks for the quick response.

Yeah, I did think of that but it just seemed a bit easier to copy the lot then delete the ones I didn't want.

I was also curious as to whether it was possible. Do you know?
 
Upvote 0
Open the 2nd workbook using:

Application.EnableEvents =False
workbook.open("")
Application.EnableEvents = True

This will keep the second workbooks' code from firing.

Brian
 
Upvote 0

Forum statistics

Threads
1,203,759
Messages
6,057,191
Members
444,913
Latest member
ILGSE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top