View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
George Nicholson[_2_] George Nicholson[_2_] is offline
external usenet poster
 
Posts: 170
Default Problems with Protect Method

I don't see any reason why the 1st sheet would be protected and other sheets
wouldn't be.

Therefo are you sure this code is even being run? (i.e., what is it that
makes you think that the first sheet is being unprotected & reprotected?)

My suspicion is that SubLockAll isn't being called and that the 1st sheet
remains untouched rather than "restored" to its original state.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"AMK4" wrote in message
...

- Excell 2003, SP2 -

I have a workbook that contains several sheets. Only the first one has
been protected. Through VBA, I'm trying to protect all the sheets, so I
do the following:


Code:
--------------------
Sub LockAll()
Dim wSheet As Worksheet
Worksheets(1).Unprotect Password:="passwd_string"
For Each wSheet In Worksheets
wSheet.Protect Password:="passwd_string"
Next
End Sub
--------------------

Can anyone tell me why it successfully Unprotects and Re-Protects ONLY
the first sheet and doesn't Protect any of the other ones? (Remember,
the other sheets don't start out Protected, only the first one does.)


--
AMK4
------------------------------------------------------------------------
AMK4's Profile:
http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=501872