LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Password Help - Urgent!

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IME MODE FOR EXCEL 2007 (URGENT URGENT) Stella Wong Excel Discussion (Misc queries) 1 August 23rd 08 11:16 PM
Urgent-Urgent VBA LOOP Jeff Excel Discussion (Misc queries) 0 October 6th 05 05:46 PM
Urgent ! how to unprotect VB macro password? starwil Excel Programming 1 May 15th 04 06:31 PM
Macro help urgent urgent Dave Peterson[_3_] Excel Programming 0 September 4th 03 03:59 PM
Macro help urgent urgent chandra Excel Programming 0 September 4th 03 03:50 PM


All times are GMT +1. The time now is 03:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"