View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default How to lock several sheets including af password?

Tyop <bg alert.

ws.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, _
Password:="Roger"

(Added a comma after the last True in the first line.)



Roger Govier wrote:

Hi
Jane

Try
Sub LockDown()
For Each ws In Worksheets
ws.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
Password:="Roger"
Next
End Sub

Sub UnlockAll()
For Each ws In Worksheets
ws.Unprotect Password:="Roger"
Next
End Sub

Make the password something far more sensible and memorable than "Roger"

--
Regards
Roger Govier

"Jane" wrote in message
...
Sooner I have asked for an easy way to lock all the sheets in a spredsheet
and I got the very useful answer:

Sub LockDown()
For Each ws In Worksheets
ws.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Next
End Sub

Sub UnlockAll()
For Each ws In Worksheets
ws.Unprotect
Next
End Sub

But I like to protect my spredsheet with a password, so the user can't
remove the protection. To that question I got the following answer:

"Open your workbook
Open the VBE (alt-f11)
select your poject
Tools|VBAProject Properties|Protection tab
Give it a memorable password.

Save your workbook, close it and reopen it to test that protection"

But I can't make that work - why?

Jane


--

Dave Peterson