代表工作表可使用的各种保护选项类型。
说明
使用 Worksheet 对象的 Protection 属性可返回一个 Protection 对象。
返回一个 Protection 对象后,就可用该对象的下列属性来设置或返回保护选项。
示例
下例通过在最上面的行中放三个成员并保留该工作表说明了如何使用 Protection 对象的 AllowInsertingColumns
属性。然后,此示例检查插入列的保护设置是否是 False,如果必要,则将其设置为 True。最后,通知用户插入一个列。
示例代码 |
function SetProtection(){
Range("A1").Formula = "1"
Range("B1").Formula = "3"
Range("C1").Formula = "4"
ActiveSheet.Protect()
// Check the protection setting of the worksheet and act accordingly.
if(ActiveSheet.Protection.AllowInsertingColumns == false){
ActiveSheet.Protect(null, null, null, null, null, null, null, null, true)
MsgBox("Insert a column between 1 and 3")
}
else{
MsgBox("Insert a column between 1 and 3")
}
}
|