View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Groups and Protected Worksheets - know if protected

So if the worksheets are protected, then protect them in a special way. But if
they're unprotected, just leave them alone?

Option Explicit
Private Sub Workbook_Open()
Dim mySheetNames As Variant
Dim iCtr As Long

mySheetNames = Array("Summary", "Concept", "Approval", _
"Definition", "Planning", _
"Implementation", "Closeout")

For iCtr = LBound(mySheetNames) To UBound(mySheetNames)
With Worksheets(mySheetNames(iCtr))
If .ProtectContents = True _
Or .ProtectDrawingObjects = True _
Or .ProtectScenarios = True Then
'protect it nicer(?)
.Protect Password:="hi", userinterfaceonly:=True
.EnableOutlining = True

'.EnableAutoFilter = True
'If .FilterMode Then
' .ShowAllData
'End If
Else
'do nothing???
End If
End With
Next iCtr
End Sub


mjones wrote:

Hi,

I've been using this Workbook code for a while and it works great to
allow protected sheets and outline to work together.

Private Sub Workbook_Open()
Dim mySheetNames As Variant
Dim iCtr As Long
mySheetNames = Array("Summary", "Concept", "Approval",
"Definition", "Planning", "Implementation", "Closeout")
For iCtr = LBound(mySheetNames) To UBound(mySheetNames)
With Worksheets(mySheetNames(iCtr))
.Protect Password:="hi", userinterfaceonly:=True
.EnableOutlining = True
'.EnableAutoFilter = True
'If .FilterMode Then
' .ShowAllData
'End If
End With
Next iCtr
End Sub

Today, I realized that it locks the worksheets every time I open the
spreadsheet.

Is there a way to recognize if the worksheets are protected or not and
leave them that way when the spreadsheet is opened?

This spreadsheet will be used by thousands of people so I'd really
appreciate help because it can't be used otherwise.

Thank you,

Michele


--

Dave Peterson