[英]Protect one worksheet with a password from showing up
Excel中是否有一种内置方法来仅使用密码保护工作簿中的一个电子表格?
当用户在控件上打勾或选择一个控件时,会在工作表可见之前提示输入密码。
如果它不是Excel内置的,可以用VBA实施吗?
您可以尝试以下方法:
VeryHidden
和“ Protected
,以使其无法从标准xl菜单中受到保护(或无法检测到) Workbook_BeforeClose
和Workbook_Open
事件上重新添加此保护 插入一个Active X
复选框并使用代码检查是否:
UnHide
表的密码。 (在此示例中使用了Fred ) 复选框代码
Private Sub CheckBox1_Click()
Dim StrPass As String
If CheckBox1.Value Then
StrPass = Application.InputBox("Please enter the password", "Admin check")
If StrPass = "fred" Then
With ThisWorkbook.Sheets("YourSheet")
.Unprotect "fred"
.Visible = xlSheetVisible
MsgBox "Sheet unhidden!", vbInformation
End With
Else
MsgBox "wrong password", vbCritical
End If
End If
End Sub
ThisWorkbook
模块
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook.Sheets("YourSheet")
.Protect "fred"
.Visible = xlVeryHidden
End With
End Sub
Private Sub Workbook_Open()
With ThisWorkbook.Sheets("YourSheet")
.Protect "fred"
.Visible = xlVeryHidden
End With
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.