And you looked under the ThisWorkbook module for a Workbook_open routine that
might call the Unprotect_all subroutine (or even workbook_beforesave)????
And remember to check under the each worksheet, too. There could be code inside
one of those modules that calls that routine.
If that doesn't work, you can try this to eliminate the macro possibility:
Close excel
windows start button|run
excel /safe
(this'll start excel in safe mode and won't allow macros to run).
File|Open your workbook.
Protect the worksheets (manually).
File|Save
File|Close
And then reopen while you're still in safe mode.
If the worksheets are still protected, I'd keep looking for a macro problem.
Roy wrote:
I don't think so to either question. I only have one file and eventhough I
do have macros in the workbook to unprotect and protect, I did not make them
run when the workbook is opened. I modified the macros that I found on this
site. Here are the macros I'm using:
Public Sub Unprotect_All()
Dim wks As Worksheet
Dim vPword As Variant
On Error Resume Next
For Each wks In ActiveWorkbook.Worksheets
With wks
.Unprotect vPword
Do While .ProtectContents
vPword = Application.InputBox( _
Prompt:="Enter password for " & .Name, _
Title:="Unprotect sheets", _
Default:="", _
Type:=2)
If vPword = False Then Exit Sub 'user cancelled
.Unprotect vPword
Loop
End With
Next
End Sub
Public Sub Protect_All()
Dim wks As Worksheet
Dim vPword As Variant
vPword = Application.InputBox( _
Prompt:="Enter Password: ", _
Title:="Protect sheets", _
Default:="", _
Type:=2)
If vPword = False Then Exit Sub 'user cancelled
For Each wks In ActiveWorkbook.Worksheets
wks.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
wks.EnableSelection = xlUnlockedCells
wks.Protect vPword
Next
End Sub
"Dave Peterson" wrote:
This isn't standard behavior.
Any chance you're opening the wrong workbook?
Or your workbook opens and a macro runs that does the unprotecting?
Roy wrote:
I have a sheet with protected cells. Everytime I re-open the file, the cells
become unprotected. How do I stop the cells from becoming unprotected?
--
Dave Peterson
--
Dave Peterson
|