Excel 2003 changes protection when saving
I have an Excel workbook with 9 worksheets on which I run a number of macros
saved with the workbook (not external). These are run in response to a
button click.
I have been applying protection to all the sheets in this workbook since it
will be used by people that don't know what they are doing in Excel. When
applying protection I only select (check) the 'Select Unlocked Cells' option
after which everything is properly locked up except for the unlocked cells.
Since the worksheets are protected so that the user can only access the
unlocked cells the macros must unlock the sheets to perform some of the
functions and then relock the sheets before the user gets control again.
The code is generally as follows...
Sheets("1st Quarter").Select
ActiveSheet.Unprotect
....
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Everything works properly during any given session. That is: After running
the macros the appropriate cells are locked and the unlocked cells are still
accessable.
However, after saving the file then reopening it the protection now has the
'Select Locked Cells' option selected as well.
If I set the protection by hand and save the workbook, close it and reopen
it everything is fine. If I make some changes that do not involve running
the macros, save, unload and reload everything is still fine.
Something happens after running the macros (any of them that unprotect then
reprotect a sheet) that causes Excel to behave correctly during the session
but to change the protection on all pages that had protection turned off/on
by the macros.
Any help on this would be greatly appreciated! TIA
Mark
|