-
Solved: Restrict Saving WorkBook
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?
[VBA]
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
MsgBox "This work book cannot be saved"
End Sub
[/VBA]
-
[VBA]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
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
Ahh excellent
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules