View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default help needed from someone with xl 2000

Hi Don,

To add to JMB's reply, v2002 took a big leap over v2000 by adding the
protection class, and its associated options. Ordinarily, protection options
applied in v2002 and later would be ignored in v2000 as "backward
compatibility" usually provides that. A problem will arise trying to
"programmatically" apply these options if your project is run in v2000 using
the later version options. Here's a sub that encapsulates this issue and some
of the most common non-persistent properties. You can use it for both v2000
and later versions.

Sub wksProtect()
' This lists all the members of the Protection class.
' Move rows around to list desired settings first,
' then comment out the lower (unwanted) settings.

With ActiveSheet
If val(Application.Version) = 10 Then
.Protect Password:=gszPwrd, _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
Userinterfaceonly:=True, _
AllowFiltering:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowDeletingColumns:=True, _
AllowDeletingRows:=True, _
AllowFormattingCells:=True, _
AllowInsertingColumns:=True, _
AllowInsertingRows:=True ', _
AllowInsertingHyperlinks:=True, _
AllowUsingPivotTables:=True
Else
.Protect Password:=gszPwrd, _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
Userinterfaceonly:=True 'Non-persistent:This one must be reset (all
versions) when the workbook is re-opened. **Requires unprotecting first**
End If

'Non-persistent settings
'These must be reset when the workbook is re-opened
'UnComment the desired setting only
' .EnableSelection = xlNoRestrictions
.EnableSelection = xlUnlockedCells
' .EnableSelection = xlNoSelection

.EnableAutoFilter = True
' .EnableAutoFilter = False
End With 'ActiveSheet

End Sub

HTH
Regards,
Garry