Requirements:
- Protect all sheets
- Hide all sheets except PERMISSIONS sheet
- Add password to the file and save it in the same path with same name without prompt
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim a110w As Variant
Dim path As String
Dim fName As String
a110w = "123" 'P
path = ThisWorkbook.path
fName = ThisWorkbook.FullName
ThisWorkbook.Unprotect Password:=a110w 'Unprotect worbook structure
For Each Worksheet In Sheets 'Protect all sheets
Worksheet.Protect Password:=a110w
Next
For Each Worksheet In Sheets 'Hide all sheets except PERMISSIONS sheet
If Not Worksheet.Name = "Permissions" Then Worksheet.Visible = xlVeryHidden
Next
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=path & fName, FileFormat:=50, Password:=a110w
ActiveWorkbook.Close savechanges:=True
Application.DisplayAlerts = True
End Sub