Skip to content
本页内容

ProtectContents (属性)

如果工作表内容是受保护的,则为 True。此属性保护单独的单元格。要打开内容保护,请使用 Protect 方法,并将 Contents 参数设置为 Truebool 类型,只读。

示例

python
#本示例判断如果 sheet1 的内容处于保护状态,则显示一个消息框
def test():
    if Worksheets.Item("Sheet1").ProtectContents:
        print("The contents of Sheet1 are protected.")
python
#本示例判断工作簿中每一张工作表的内容是否处于保护状态
def test():
    for i in range(1, ActiveSheet.Sheets.Count):
        sheet = Application.Sheets.Item(i)
        if sheet.ProtectContents:
            print(f"工作表 {sheet.Name} 的内容处于保护状态")
        else:
            print(f"工作表 {sheet.Name} 的内容未处于保护状态")