View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
hotherps[_149_] hotherps[_149_] is offline
external usenet poster
 
Posts: 1
Default Protect sheets w/o user password prompt


When I run this code in the open workbook event. It locks all of th
formulas but still allows the use of command buttons.

But if I uncomment the line below it promps the user for a passwor
once for each sheet in the workbook(9 shts)

If I comment it out it protects everything I want but protection can b
turned off without a password

Dim Sht As Worksheet
Const Pass As String = "hello"

On Error Resume Next
For Each Sht In ThisWorkbook.Worksheets
With Sht
.Protect UserInterFaceOnly:=True
'.Unprotect Password:=Pass
.cells.Locked = False
.cells.SpecialCells(xlCellTypeFormulas).Locked = True
.Protect Password:=Pass
End With
Next Sh

--
hotherp
-----------------------------------------------------------------------
hotherps's Profile: http://www.excelforum.com/member.php...nfo&userid=505
View this thread: http://www.excelforum.com/showthread.php?threadid=32005