Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In a code module I have this declaration:
Public Const Password = "Test" In Thisworkbook I have this code: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) ProtectSheets End Sub Private Sub ProtectSheets() Dim WKS As Worksheet For Each WKS In Worksheets If WKS.Visible < xlSheetVeryHidden Then WKS.Protect Password, DrawingObjects:=True, Contents:=True, Scenarios:=True WKS.EnableSelection = xlUnlockedCells End If Next WKS End Sub The aim is when the workbook is saved all sheets are protected with the default password. However after the code runs and the workbook saves itself, the worksheets cannot be unprotected!!!! Or at least not by entering the password "Test". Can anyone explain what is happening, and how to achieve what I want to achieve. This has happened to me twice now, and after the first time I saved a back-up before I ran the _BeforeSave code so I would not 'lose' my work. However can anyone explain this??? Paul Smith |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
IME MODE FOR EXCEL 2007 (URGENT URGENT) | Excel Discussion (Misc queries) | |||
Urgent-Urgent VBA LOOP | Excel Discussion (Misc queries) | |||
Urgent ! how to unprotect VB macro password? | Excel Programming | |||
Macro help urgent urgent | Excel Programming | |||
Macro help urgent urgent | Excel Programming |