AutoSave on exit stopped working

Mech.Mon

New Member
Joined
May 8, 2012
Messages
3
My PERSONAL.xlsb has been set up for years to save before exit without the prompt to save. Now it has stopped working. It does not matter if the worksheet is opened individually or after taking the focus after closing another sheet.
In VBAProject>>ExcelObject>ThisWorkbook

VBA Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Tried Private and Public

'Fails
'Workbooks("PERSONAL.xlsb").Activate
'Me.Save

'Fails
'ThisWorkbook.Saved = True
'ThisWorkbook.Save

'Fails
Application.DisplayAlerts = False
ThisWorkbook.Saved = True
ThisWorkbook.Save
Application.DisplayAlerts = True

'Created Macro in a module with the previous code.
'Fails
'Call Close_Book

I just tried putting a messagebox in the Workbook_BeforeClose event and it never fired.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Run this macro to check if Events have somehow been disabled.

VBA Code:
'Check if events are enabled.
Sub TurnOnEventsIfOff()
    If Not Application.EnableEvents Then
        Select Case MsgBox("Events are off!" & vbCrLf & vbCrLf & "Turn them back on?", vbYesNo Or vbExclamation, Application.Name)
        Case vbYes
            Application.EnableEvents = True
        End Select
    End If
End Sub
 
Upvote 0
I've already done that.

VBA Code:
With Application
        .ScreenUpdating = True
        .EnableEvents = True
        .DisplayAlerts = True      
End With

Application.Calculation = xlAutomatic

So I copied every sheet into a new WkBk, imported all the modules and user forms from the original. Saved to XLSTART. Went through a few rounds of open and closing both files with making edits and no edits. Original WkBk would only fire Before_Close event sporadically. Then noticed my XLAMs were not loading so had to regedit HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Excel\Options and rewrite the OPEN keys so that there were no blanks between entries. That and new workbook seems to have solved it.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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