Jamie Walker
Jamie Walker

Reputation: 213

How to cancel Workbook_BeforeSave

I got this code from the Microsoft website.

The file saves whether I select Yes or No.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel as Boolean)
 
a = MsgBox("Do you really want to save the workbook?", vbYesNo) 
If a = vbNo Then Cancel = True 

End Sub

Upvotes: 0

Views: 111

Answers (1)

Red Hare
Red Hare

Reputation: 687

What happens if you test

IF MsgBox("Do you really want to save the workbook?", vbYesNo) = vbNo then Cancel=True

Upvotes: 2

Related Questions