保护多张纸张并保持保护,直到重新输入密码

时间:2017-01-30 16:06:48

标签: excel vba excel-vba

我有这个代码可以同时保护多个工作表,但是当我重新打开文件时,保护就消失了。将文件上载到SharePoint时,如何保持这一点。但是,将来我应该能够重新输入密码进行更改。

OR

告诉我任何其他方式我可以将此表格只读给其他人(即使他们尝试也无法编辑它)。

Sub protect_all_sheets()
top:
pass = InputBox("password?")
repass = InputBox("Verify Password")
If Not (pass = repass) Then
MsgBox "you made a boo boo"
GoTo top
End If
For i = 1 To Worksheets.Count
If Worksheets(i).ProtectContents = True Then GoTo oops
Next
For Each s In ActiveWorkbook.Worksheets
s.Protect Password:=pass
Next
Exit Sub
oops: MsgBox "I think you have some sheets that are already protected. Please unprotect all sheets then running this Macro."
End Sub

谢谢!

0 个答案:

没有答案
相关问题