Adding a BeforeClose event to a Workbook created using Workbooks.Add

Maximus Tatius

New Member
Joined
Oct 19, 2008
Messages
41
I have a fairly complex workbook which contains a worksheet I use as a template for a new workbook - I populate this as part of a long script which fires when I click a command button on a form, then copy this sheet to a new workbook which I create and save in the same script.

This works fine but it would be perfect if I could find a way to programmatically add a BeforeClose event to that new workbook.

Is that possible, or should I be looking at not using Workbooks.Add to create the new workbook and (instead) using a workbook template which already has the BeforeClose event written into it?

I did find this VERY old bit of coding which suggests that it IS possible, though I must admit I found it a bit confusing.

For information the BeforeClose event is to turn automatic calculation off, if that's what the user had his application set as, before they open the new workbook.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
It is possible, but I would suggest using a template workbook if that is an option for you. It's much simpler to code and less problematic in use.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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