I opened a spreadsheet from the State of Utah dealing with air emissions, and there was a macro/script to disallow unprotecting the sheet. The trouble is that now I cannot protect or unprotect any spreadsheets, period. I've reinstalled Office to no avail. My Office version is 2003. I've looked at the code, but I don't see a way to reverse the changes. Does anyone know where this type of security setting might be found (registry, etc.) and how I can change it back? Here's the code that causes the problem:
Sub ProtectSheets()
'
' This macro protects all of the sheets in the active workbook, as well
' as the workbook itself. It protects everything with the correct
' password using the variable "Password". "Password" is a public
' string variable that is defined in Module1. If the user does not have
' permission to enter the password ("blnPermission = False") then this
' macro is terminated ("Exit Sub"). "blnPermission" is a public variable
' that also is defined in Module1.
'
If blnPermission = False Then
Exit Sub
End If
'
' "Sheets" is an array that is internal to Excel. It holds all of the
' worksheets and all of their related properties.
'
' The "If" statement inbeded within the following "For" loop ensures that
' the printout sheets don't get protected. This is so that the user is
' allowed to manipulate them as he/she pleases.
'
For Each Wks In Sheets
If Len(Wks.Name) > 4 And InStr(1, Wks.Name, "F") <> 1 _
And Wks.Name <> "Tanks" And Wks.Name <> "Detailed Summary" Then
'Debug.Print Wks.Name
Wks.Protect Password:=PWord ', DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End If
Next Wks
If ExistSheet("Tanks") Then
Sheets("Tanks").Protect ("Tanks")
End If
ThisWorkbook.Protect Password:=PWord ', Structure:=True, Windows:=True
'
' The following code changes the caption on the command button found on
' the "INPUT" sheet to "Unprotect".
'
Sheets("INPUT").cmdProtection.Caption = "Unprotect"
End Sub
Thankd for any help you can provide!
Mike
![[morning] [morning] [morning]](/data/assets/smilies/morning.gif)
Sub ProtectSheets()
'
' This macro protects all of the sheets in the active workbook, as well
' as the workbook itself. It protects everything with the correct
' password using the variable "Password". "Password" is a public
' string variable that is defined in Module1. If the user does not have
' permission to enter the password ("blnPermission = False") then this
' macro is terminated ("Exit Sub"). "blnPermission" is a public variable
' that also is defined in Module1.
'
If blnPermission = False Then
Exit Sub
End If
'
' "Sheets" is an array that is internal to Excel. It holds all of the
' worksheets and all of their related properties.
'
' The "If" statement inbeded within the following "For" loop ensures that
' the printout sheets don't get protected. This is so that the user is
' allowed to manipulate them as he/she pleases.
'
For Each Wks In Sheets
If Len(Wks.Name) > 4 And InStr(1, Wks.Name, "F") <> 1 _
And Wks.Name <> "Tanks" And Wks.Name <> "Detailed Summary" Then
'Debug.Print Wks.Name
Wks.Protect Password:=PWord ', DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End If
Next Wks
If ExistSheet("Tanks") Then
Sheets("Tanks").Protect ("Tanks")
End If
ThisWorkbook.Protect Password:=PWord ', Structure:=True, Windows:=True
'
' The following code changes the caption on the command button found on
' the "INPUT" sheet to "Unprotect".
'
Sheets("INPUT").cmdProtection.Caption = "Unprotect"
End Sub
Thankd for any help you can provide!
Mike
![[morning] [morning] [morning]](/data/assets/smilies/morning.gif)