dlmille
asked on
Why does Sheet1.Protect not work properly when including more than a few of the parameters?
I have a utility I've almost completed as part of a question I've answered on E-E. This utility allows one to specify the Protect options on each sheet in the workbook.
My command looks like:
dim mySheet as Worksheet
'Now protect the sheet with appropriate options
mySheet.Protect Password:=mypwd, DrawingObjects:=bDrawingOb jects, Contents:=bContents, Scenarios:=bScenarios, UserInterfaceOnly:=bUserIn terfaceOnl y, _
AllowFormattingCells:=bAll owFormatti ngCells, AllowFormattingColumns:=bA llowFormat tingColumn s, AllowFormattingRows:=bAllo wFormattin gRows, _
AllowInsertingColumns:=bAl lowInserti ngColumns, AllowInsertingRows:=bAllow InsertingR ows, AllowInsertingHyperlinks:= bAllowInse rtingHyper links, _
AllowDeletingColumns:=bAll owDeleting Columns, AllowDeletingRows:=bAllowD eletingRow s, AllowSorting:=bAllowSortin g, AllowFiltering:=bAllowFilt ering, _
AllowUsingPivotTables:=bAl lowUsingPi votTables
Where each of the parameters get a TRUE/FALSE, based on user selection. When I test this the sheet does NOT get protected.
The sheet does NOT get protected when I try:
mySheet.Protect mypwd, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False
Why is this? I can protect it if I only specify a couple of the parameters after the password, but not ALL of them, or even more than a few...
Help!
Thanks!
Dave
My command looks like:
dim mySheet as Worksheet
'Now protect the sheet with appropriate options
mySheet.Protect Password:=mypwd, DrawingObjects:=bDrawingOb
AllowFormattingCells:=bAll
AllowInsertingColumns:=bAl
AllowDeletingColumns:=bAll
AllowUsingPivotTables:=bAl
Where each of the parameters get a TRUE/FALSE, based on user selection. When I test this the sheet does NOT get protected.
The sheet does NOT get protected when I try:
mySheet.Protect mypwd, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False
Why is this? I can protect it if I only specify a couple of the parameters after the password, but not ALL of them, or even more than a few...
Help!
Thanks!
Dave
The other parameters are all what is allowed given a protected worksheet.
Kevin
Kevin
ASKER
So
mySheet.Protect Password:=myPwd
with no other parameters then implies one of these parameters you mention are TRUE? Is it correct to assume if a parameter is omitted, its value is FALSE? If that's the case, how is it that this command works?
Thanks,
Dave
mySheet.Protect Password:=myPwd
with no other parameters then implies one of these parameters you mention are TRUE? Is it correct to assume if a parameter is omitted, its value is FALSE? If that's the case, how is it that this command works?
Thanks,
Dave
The default values for the first three parameters is True.
Kevin
Kevin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ouch - I should have read that much more carefully - I got all the parameters but didn't look at defaults - I assumed and you know what that means. Fortunately, you helped me avoid beating my head against the wall too much.
Much appreciated!
Dave
Much appreciated!
Dave
DrawingObjects, Contents, Scenarios
Kevin