【发布时间】:2019-03-30 09:39:40
【问题描述】:
我构建了一个小型 Excel 工具,它基本上要求用户输入一些成本元素并输出输出。在管理员模式下,我创建了锁定和解锁按钮,允许管理员用户保护和取消保护所有工作表以进行编辑。我的工具里总共有 10 张纸。除了两张纸之外,按钮工作正常。
Unlock 宏取消保护除 Cost Inputs 工作表之外的所有工作表。但是,如果我使用一小段代码在即时窗口中解除成本输入表的保护,它就可以正常工作!
Sub admin_unlock_Click()
Application.ScreenUpdating = False
Sheets("Home").Unprotect Password:="xxx"
Sheets("Cover Page").Unprotect Password:="xxx"
Sheets("Study Categorization").Unprotect Password:="xxx"
Sheets("Cost Inputs").Unprotect Password:="xxx"
Sheets("Price Indicators").Unprotect Password:="xxx"
Sheets("Benchmarking Output").Unprotect Password:="xxx"
Sheets("Output Sheet").Unprotect Password:="xxx"
Sheets("Instructions").Unprotect Password:="xxx"
Sheets("Glossary").Unprotect Password:="xxx"
Sheets("Export to CRM").Unprotect Password:="xxx"
Application.ScreenUpdating = True
End Sub
Lock 宏保护除输出表一以外的所有表。如果我将相关的代码放在即时窗口中,它也不起作用。
Sub admin_lock_Click()
Application.ScreenUpdating = False
Sheets("Home").Protect Password:="xxx", UserInterFaceOnly:=True
Sheets("Cover Page").Protect Password:="xxx", UserInterFaceOnly:=True
Sheets("Study Categorization").Protect Password:="xxx", UserInterFaceOnly:=True
Sheets("Cost Inputs").Protect Password:="xxx", UserInterFaceOnly:=True
Sheets("Price Indicators").Protect Password:="xxx", UserInterFaceOnly:=True
Sheets("Benchmarking Output").Protect Password:="xxx", UserInterFaceOnly:=True
Sheets("Output Sheet").Protect Password:="xxx", UserInterFaceOnly:=True
Sheets("Instructions").Protect Password:="xxx", UserInterFaceOnly:=True
Sheets("Glossary").Protect Password:="xxx", UserInterFaceOnly:=True
Sheets("Export to CRM").Protect Password:="xxx", UserInterFaceOnly:=True
Application.ScreenUpdating = True
End Sub
知道这里可能出了什么问题吗?
谢谢! 道姆89
【问题讨论】:
-
如果他们都有一个共享密码,我会在这里考虑一个表单循环。另外,如果是这样,为什么不锁定/解锁这本书?