I can't seem to get this to work:
The Protection toolbar should open when the workbook file opens.
BTW, will I get an error if the toolbar is already open?
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Application.CommandBars("Protection").Visible = True
Dim SH As Worksheet
Dim rng As Range
On Error Resume Next
For Each SH In Worksheets
SH.Unprotect
With SH.UsedRange
.Locked = False
Set rng = Nothing
Set rng = .SpecialCells(xlCellTypeFormulas)
If Not rng Is Nothing Then
rng.Locked = True
End If
End With
SH.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowInsertingColumns:=True, AllowInsertingRows:=True
Next SH
Application.CommandBars("Protection").Visible = False
Application.ScreenUpdating = True
End Sub
The Protection toolbar should open when the workbook file opens.
BTW, will I get an error if the toolbar is already open?
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Application.CommandBars("Protection").Visible = True
Dim SH As Worksheet
Dim rng As Range
On Error Resume Next
For Each SH In Worksheets
SH.Unprotect
With SH.UsedRange
.Locked = False
Set rng = Nothing
Set rng = .SpecialCells(xlCellTypeFormulas)
If Not rng Is Nothing Then
rng.Locked = True
End If
End With
SH.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowInsertingColumns:=True, AllowInsertingRows:=True
Next SH
Application.CommandBars("Protection").Visible = False
Application.ScreenUpdating = True
End Sub