Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Check for Sheet Password Protected, Unprotect with multiple pa

Thank you very much....it works perfectly! I did not write the original code
or create the worksheets, but your suggestion is noted. Thanks again!

"michael.beckinsale" wrote:


David,

You have to check what method of protection is applied to the
ActiveSheet and the available methods vary between the different
versions of Excel97, 2000, 2003.

For future reference if you want to change things using VBA code but
want the sheet protected to the user you can protect the sheet using
the UserInterfaceOnly method.

Assuming that the ActiveSheet has been 'generally' protected the
following code should work. The variable 'pwd' will contain the actual
password used to unprotect the sheet.

Sub Password_Checker()

Dim pwd As String

On Error Resume Next
With ActiveSheet
If ActiveSheet.ProtectContents = True Then
.Unprotect Password:="pass1"
If ActiveSheet.ProtectContents = False Then
pwd = "pass1"
Else
.Unprotect Password:="pass2"
pwd = "pass2"
End If
End If
End With

End Sub

Regards

Michael Beckinsale


Reply
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
I need to unprotect sheet so I cn sve it but need a password? scout ron Excel Discussion (Misc queries) 2 May 28th 10 03:05 PM
unprotect check box in protected worksheet Laura Bennett Excel Discussion (Misc queries) 1 September 12th 06 05:12 PM
password protected a check box Glendon MacBurnie Excel Worksheet Functions 0 January 27th 05 07:52 PM
How can I unprotect a worksheet that is password protected Password Excel Discussion (Misc queries) 3 December 30th 04 06:13 PM
How can i unprotect a workbook in Excell when I forgot the passwo. Kevin1961 Excel Worksheet Functions 2 October 29th 04 08:58 AM


All times are GMT +1. The time now is 07:31 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"