【发布时间】:2023-03-06 19:53:01
【问题描述】:
我有两个非常简单的子程序来保护和取消保护带有密码的工作表。在我添加“AllowFiltering:=True”参数之前,Subs 工作得很好。
添加该参数后,取消保护工作表时会提示我输入密码。但是,如果我按取消,则工作表不受保护(应该如此)。
因此,密码提示似乎完全多余,但有人可以帮我摆脱它吗?
这两个子是:
Sub LockSheet()
If ActiveSheet.Protect = False Then
ActiveSheet.Protect Password:="TopSecretPW", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFiltering:=True
End If
End Sub
Sub UnlockSheet()
If ActiveSheet.Unprotect = False Then
ActiveSheet.Unprotect Password:="TopSecretPW"
End If
End Sub
如果我使用此宏 - 没有 AllowFiltering:=True 参数 - 系统不会提示我输入密码。
Sub LockSheet()
If ActiveSheet.Protect = False Then
ActiveSheet.Protect Password:="TopSecretPW", DrawingObjects:=True, Contents:=True, Scenarios:=True
End If
End Sub
奖励信息:过滤器和保护在参数集下工作得很好,如果没有输入正确的密码,我无法从菜单中取消保护工作表。我想埋葬的只是那个不请自来的私信提示。
【问题讨论】: