cancel save

G

Guest

i want a pre-save program to check if there is a value in cell a1 before
someone saves. if there is, and user clicks 'No' then it will cancel saving.

thank you

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

If Range("a1") = 1 Then aaa = MsgBox("Are you Sure?", vbCritical + vbYesNo,
"Dont want to Ruin Template!")

If aaa = vbNo Then ...

end sub
 
G

Guest

Hi lawson.
If you look at the help on line you will find:

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

Regards
Eliano
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top