excel vba prevent saving workbook excel vba prevent save

The solution for “excel vba prevent saving workbook excel vba prevent save” can be found here. The following code will assist you in solving the problem.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True ‘ Cancels in any case
‘ Or :
If SaveAsUI Then Cancel = True ‘ Cancels only if saving is asked by user, not via code
End Sub

‘ Prevents Excel from requesting a save before closing
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ThisWorkbook.Saved = True
End SubPrivate Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
msgbox “Forbidden.”
End Sub

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts