因此,当我的宏运行时,我有这些简单的sub来解除保护而不是保护东西,唯一的问题是我的一些工作表实际上是图表,并且在调用这些子服务器时它们不受保护。如何更改我的代码以合并图表?谢谢!
Sub UnprotectAll()
Dim AdminPassword As String
AdminPassword = "password"
ActiveWorkbook.Unprotect ("Evaluate(AdminPassword)")
For Each sh In ActiveWorkbook.Worksheets
sh.Unprotect Password:=AdminPassword
Next sh
End Sub
Sub ProtectAll()
Dim AdminPassword As String
AdminPassword = "password"
ActiveWorkbook.Protect ("Evaluate(AdminPassword)")
For Each sh In ActiveWorkbook.Worksheets
sh.Protect Password:=AdminPassword
Next sh
End Sub
答案 0 :(得分:4)
将ActiveWorkbook.Worksheets
替换为ActiveWorkbook.Sheets