![]() |
protect and unprotect
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 |
protect and unprotect
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 |
protect and unprotect
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 |
All times are GMT +1. The time now is 07:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com