Sunday 14 January 2018

How to disable saving of an Excel file | Stop user from saving an Excel file

If you wish to stop a user from saving a file, you can use below in the workbook code.

Note : Make sure you put some thoughtful conditions before the 'Cancel = True' , so only you or dedicated people are allowed to save the file.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    If Environ("username") <> "mm" Then Cancel = True
End Sub

No comments:

Post a Comment