Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi - I am either missing something really simple or something else is
happening: This works fine... sub proc i_protect Dim mySheet As Worksheet For Each mySheet In Worksheets mySheet.protect ("abc1234") Next mySheet end sub This says the password is incorrect... sub proc i_unprotect Dim mySheet As Worksheet For Each mySheet In Worksheets mySheet.Unprotect ("abc1234") Next mySheet end sub Any ideas? Thanks Andrew |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In ,
Andrew wrote: Hi - I am either missing something really simple or something else is happening: This works fine... sub proc i_protect Dim mySheet As Worksheet For Each mySheet In Worksheets mySheet.protect ("abc1234") Next mySheet end sub This says the password is incorrect... sub proc i_unprotect Dim mySheet As Worksheet For Each mySheet In Worksheets mySheet.Unprotect ("abc1234") Next mySheet end sub Any ideas? Thanks Andrew Hi Andrew, just tested it (I had to remove proc statements (what are these for?)). Excel 2003 - works fine (protect and unprotect) Are both procedures referring to the same workbook? cheers, Stephan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just a guess but one of your sheets is protected with a different password.
Give this code a try... Sub i_protect() Dim mySheet As Worksheet For Each mySheet In Worksheets mySheet.Protect "abc1234" Next mySheet End Sub Sub i_unprotect() Dim mySheet As Worksheet On Error GoTo ErrorHandler For Each mySheet In Worksheets mySheet.Unprotect "abc1234" Next mySheet Exit Sub ErrorHandler: MsgBox "Sheet " & mySheet.Name & " could not be unprotected.", vbInformation Resume Next End Sub -- HTH... Jim Thomlinson "Andrew" wrote: Hi - I am either missing something really simple or something else is happening: This works fine... sub proc i_protect Dim mySheet As Worksheet For Each mySheet In Worksheets mySheet.protect ("abc1234") Next mySheet end sub This says the password is incorrect... sub proc i_unprotect Dim mySheet As Worksheet For Each mySheet In Worksheets mySheet.Unprotect ("abc1234") Next mySheet end sub Any ideas? Thanks Andrew |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Protect, unprotect | Excel Discussion (Misc queries) | |||
protect and unprotect | Excel Programming | |||
Password - Protect, UnProtect | Excel Programming | |||
Unprotect and protect.... | Excel Programming | |||
Thanks Otto.......Unprotect and re-Protect | Excel Programming |