• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Cancel Save/Save As except through Macro

jsabin

New Member
Here's what I'm using to stop anyone from saving a file. What I would like to do is to only allow a file to be saved through a macro assigned to a button on a sheet.
Thanks,

[Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "OH NO YOU DON'T!!!"
Cancel = True
End Sub]
 
Hello
Give this a try
Code:
'In Workbook Module
'------------------
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    If Not saveMode Then
        MsgBox "Oh No You Can't Save!" & vbCrLf & "Please Use The Save Button On Worksheet", vbExclamation
        Cancel = True
    End If
End Sub

'In Standard Module
'------------------
Public saveMode As Boolean

Sub SaveMe()
    saveMode = True
    ThisWorkbook.Save
    saveMode = False
End Sub
 
Back
Top