Suppress an Excel Error message caused by save button before going into `Workbook_BeforeSave` event

59 Views Asked by At

While manually saving an Excel Addin file as xla I'm unable to suppress an Excel eror message. The error measage occurs before the Workbook_BeforeSave event is triggered.
In Workbook_BeforeSave event I am setting the IsAddin back to TRUE, and the file is saved, just want to block the error notification that makes the user have to press OK and then realize that the error was not a real problem. If the Workbook_BeforeSave is not really exactly before the save what other event happens earlier that I can manipulate with vba? How could I hide the unnessecery measage from the user and let the user just press Excels regular save button?

 Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'MsgBox "Workbook_BeforeSave triggered"

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False

If Not ThisWorkbook.IsAddin Then
        ThisWorkbook.IsAddin = True
End If
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Application.EnableEvents = True
End Sub

Private Sub showSheetsOfAddin()
If ThisWorkbook.IsAddin Then
 ThisWorkbook.IsAddin = False
End If
End Sub
0

There are 0 best solutions below