SetProtection

Set the protection properties of the workbook, worksheet, or specific cells.

Overloads

Overload Name Description
Cells Set protection parameters of specified cells.
Sheets Set protection parameters of specified sheets.
Workbook Set protection parameters of the workbook.


Cells

Set protection parameters of specified cells.

Argument Description
SpecifySheetBy Select how to specify which worksheet to select while the method is being executed.
Specify one of the following values or an arbitrary value: <blank>SheetNameSheetNumberAllSheets
SheetSpec Specify the sheet-name or sheet-number, depending on SpecifySheetBy. If SpecifySheetBy is AllSheets then SheetSpec can be left empty.
Address The address of a range to select for the execution of the method.
CellByCell Whether to execute the method on a cell-by-cell basis, or on the range specified by the address.
ReverseOrder Whether to loop through the rows and columns from highest to lowest. Only applies when CellByCell is true.
MethodCondition If the result of method-condition expression resolves to FALSE, then the method is not executed.
Specify one of the following values or an arbitrary value: <blank>FALSETRUE
CellCondition If the result of the condition expression resolves to FALSE, then the current cell is skipped.
Specify one of the following values or an arbitrary value: <blank>FALSETRUE
Locked Whether the specified cell(s) are locked.
Specify one of the following values or an arbitrary value: <blank>FALSETRUE
FormulasHidden Whether the specified cell(s)' formulas are hidden.
Specify one of the following values or an arbitrary value: <blank>FALSETRUE

Sheets

Set protection parameters of specified sheets.

Argument Description
SpecifySheetBy Select how to specify which worksheet to select while the method is being executed.
Specify one of the following values or an arbitrary value: <blank>SheetNameSheetNumberAllSheets
SheetSpec Specify the sheet-name or sheet-number, depending on SpecifySheetBy. If SpecifySheetBy is AllSheets then SheetSpec can be left empty.
Address The address of a range to select for the execution of the method.
CellByCell Whether to execute the method on a cell-by-cell basis, or on the range specified by the address.
ReverseOrder Whether to loop through the rows and columns from highest to lowest. Only applies when CellByCell is true.
MethodCondition If the result of method-condition expression resolves to FALSE, then the method is not executed.
Specify one of the following values or an arbitrary value: <blank>FALSETRUE
CellCondition If the result of the condition expression resolves to FALSE, then the current cell is skipped.
Specify one of the following values or an arbitrary value: <blank>FALSETRUE
Protected
For the Worksheet overload, enables or disables protection for the worksheet.
For the Workbook overload, controls whether the specified Password is required to open and/or unprotect the workbook.
Specify one of the following values or an arbitrary value: <blank>FALSETRUE
SheetVisibility Whether the specified sheet(s) are Visible, Hidden, or VeryHidden.
Specify one of the following values or an arbitrary value: <blank>VisibleHiddenVeryHidden
Password
For the Worksheet overload, the password to set for the sheet.
For the Workbook overload, the password which will be required to unprotect the workbook structure. (The password is not required to open the workbook.)

Workbook

Set protection parameters of the workbook.

Argument Description
SpecifySheetBy Select how to specify which worksheet to select while the method is being executed.
Specify one of the following values or an arbitrary value: <blank>SheetNameSheetNumberAllSheets
SheetSpec Specify the sheet-name or sheet-number, depending on SpecifySheetBy. If SpecifySheetBy is AllSheets then SheetSpec can be left empty.
Address The address of a range to select for the execution of the method.
CellByCell Whether to execute the method on a cell-by-cell basis, or on the range specified by the address.
ReverseOrder Whether to loop through the rows and columns from highest to lowest. Only applies when CellByCell is true.
MethodCondition If the result of method-condition expression resolves to FALSE, then the method is not executed.
Specify one of the following values or an arbitrary value: <blank>FALSETRUE
CellCondition If the result of the condition expression resolves to FALSE, then the current cell is skipped.
Specify one of the following values or an arbitrary value: <blank>FALSETRUE
StructureProtected
Whether the structure (number and order of worksheets) of the workbook is protected from changes.
When the structure is protected, a user cannot add, delete, or rename worksheets or display hidden worksheets.
When the StructureProtected is True and a Password is specified, the user is not able to unprotect the workbook.
Specify one of the following values or an arbitrary value: <blank>FALSETRUE
Password
For the Worksheet overload, the password to set for the sheet.
For the Workbook overload, the password which will be required to unprotect the workbook structure. (The password is not required to open the workbook.)
RecommendReadOnly Whether to turn on RecommendReadOnly.
Specify one of the following values or an arbitrary value: <blank>FALSETRUE