PDA

View Full Version : Solved: Restrict Saving WorkBook



gimli
04-12-2010, 05:20 AM
Hi,

I want to restrict people from saving a workbook using the code below. Problem is when I try to save changes after adding the code it wont let me either ...ha

How can I add code to restrict saving?


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
MsgBox "This work book cannot be saved"
End Sub

mdmackillop
04-12-2010, 05:47 AM
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True

If Environ("username") = "MD" Then '<=== Change to suit
Application.EnableEvents = False
ThisWorkbook.Save
Application.EnableEvents = True
Else
MsgBox "This work book cannot be saved"
End If

End Sub

gimli
04-12-2010, 08:39 AM
Ahh excellent

:clap: