H
hervinder
I have a workbook which has grouping on certain sheets, i want the workbook
to protect itself everytime a user closes it. The problem i'm having is that
when the workbook is opened the sheets are protected but the user cannot
expand the groups. I have written the code below
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim sht as Workbooksheet
For Each sht In ActiveWorkbook.Worksheets
sht.Activate
With Worksheets(ActiveSheet)
.Protect Password:="pwd", Contents:=True, UserInterfaceOnly:=True
.EnableOutlining = True
End With
Next sht
End sub
I'm sure its something simple that i'm doing wrong, can someone please help?
to protect itself everytime a user closes it. The problem i'm having is that
when the workbook is opened the sheets are protected but the user cannot
expand the groups. I have written the code below
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim sht as Workbooksheet
For Each sht In ActiveWorkbook.Worksheets
sht.Activate
With Worksheets(ActiveSheet)
.Protect Password:="pwd", Contents:=True, UserInterfaceOnly:=True
.EnableOutlining = True
End With
Next sht
End sub
I'm sure its something simple that i'm doing wrong, can someone please help?