Private Sub Workbook_Open()
'
' Do the required stuff when the workbook is opened.
'
Dim WorkSht As Worksheet, ThisChart As Chart
'
' ************************************************************************
' Protect all worksheets & chartsheets, and the workbook itself.
' ************************************************************************
'
PsWd = "Whatever"
'
' Loop through all the worksheets.
'
For Each WorkSht In Worksheets
WorkSht.Protect DrawingObjects:=True, Contents:=True, _
Scenarios:=True, Password:=PsWd
'
' Allow user to select (but not change) locked cells.
' Note that with some versions of Excel this setting does not
' persist (ie it gets forgotten when the workbook is saved).
'
WorkSht.EnableSelection = xlNoRestrictions
Next WorkSht
'
' Loop through all the charts.
'
For Each ThisChart In Charts
ThisChart.Protect DrawingObjects:=True, Contents:=True, _
Scenarios:=True, Password:=PsWd
Next ThisChart
'
' Protect the workbook itself.
'
ActiveWorkbook.Protect Structure:=True, Windows:=False, _
Password:=PsWd
'
End Sub