Worksheet.Protection 属性 (Excel)

返回一个 Protection 对象,该对象代表工作表的保护选项。

语法

表达式保护

表达 一个代表 Worksheet 对象的变量。

示例

本示例对活动工作表进行保护,并判断是否能在受保护的工作表中插入列,然后将此状态通知用户。

Sub CheckProtection() 
 
 ActiveSheet.Protect 
 
 ' Check the ability to insert columns on a protected sheet. 
 ' Notify the user of this status. 
 If ActiveSheet.Protection.AllowInsertingColumns = True Then 
 MsgBox "The insertion of columns is allowed on this protected worksheet." 
 Else 
 MsgBox "The insertion of columns is not allowed on this protected worksheet." 
 End If 
 
End Sub

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。