Workbook_BeforeClose not triggering

roscoe

Well-known Member
Joined
Jun 4, 2002
Messages
1,046
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I have a template with a workbook_open event that works like a champ. Within that routine I save (to a cell) the user's default file save format. Then I change the format to macroenabled so that the template can be saved with macros intact without the users having to remember to change the setting (trivial I know, but my customer whine a lot about the simplest things...maybe that's a good sign that the big stuff works fine).

Anyway, I also have a Workbook_BeforeClose event where I want to reset the user's default file save format back to where it was when the file was opened. Problem is the Workbook_BeforeClose event is not triggering. I know this because I inserted both a Stop command for debugging as well as a breakpoint and it never stops.

Her's the basics of the code if it helps:
Code:
Private Sub Workbook_Open()
    Range("Start") = Application.DefaultSaveFormat
    Application.DefaultSaveFormat = xlOpenXMLWorkbookMacroEnabled
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Stop
    Application.DefaultSaveFormat = Range("Start")
End Sub


Ideas?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
That was exactly the problem...thanks!
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

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