Costas
Member
Hi Chandoo,
I've written some code for the before close event so that I unprotect my workbook, hide all sheets but a blank one and password protect my workbook again. All this is working fine but I keep getting asked if I want to save changes after I run all the code which means that the user will be able to see the changes I've done. Is it possible to avoid getting asked to save?
Thanks
Costas
I've written some code for the before close event so that I unprotect my workbook, hide all sheets but a blank one and password protect my workbook again. All this is working fine but I keep getting asked if I want to save changes after I run all the code which means that the user will be able to see the changes I've done. Is it possible to avoid getting asked to save?
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Are you sure that you want to close this workbook ?", 36, "Confirm") = vbNo Then
Cancel = True
Else:
ActiveWorkbook.Save
Cancel = False
Application.ScreenUpdating = False
UnprotectWorkbook
Sheets("Sheet1").Visible = True
For Each MySheet In MyBook.Worksheets
If MySheet.Name = "Sheet1" Then
MySheet.Visible = True
Else
MySheet.Visible = False
End If
Next MySheet
ProtectWorkbook
End If
End Sub
Thanks
Costas