共用方式為


Excel) (Worksheet.Protection 屬性

會傳回 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 支援與意見反應