当使用密码重置当前文件上的密码时,一旦重新保护,“格式化列和格式化文件,自动过滤器”选项将禁用。我们不需要这些选项的所有文件的基础上的要求将启用这些选项&如果密码,我们与用户共享将重置密码的宏在那个时候,这些选项是dissabling。任何人都可以提供解决我的问题。谢谢
Sub Main_Protect()
Dim PWD As String
Dim WB As Workbook
Dim ws As Worksheet
Dim rng As Range, cell As Range
Dim sht As Worksheet
PWD = ThisWorkbook.Sheets("Main").Range("D1").Value
'If PWD = "" Then
'PWD = InputBox("Please Enter the password")
'End If
Set WB = Application.Workbooks.Open(ThisWorkbook.Sheets("Main").Cells(13, 1))
' Loop through all sheets in the workbook
LR = ThisWorkbook.Sheets("Tab").Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
Set rng = ThisWorkbook.Sheets("Tab").Range("A2:A" & LR)
For Each cell In rng
If cell > 0 Then
WB.Activate
Set ws = WB.Sheets(cell.Value)
ws.Protect PWD,Contents:=True, UserInterfaceOnly:=True
ThisWorkbook.Sheets("Tab").Range("B" & ThisWorkbook.Sheets("Tab").Cells(Rows.Count, 2).End(xlUp).Row + 1).Value = "Yes"
End If
Next cell
MsgBox "Done"
WB.Save
WB.Close
End Sub
是否有任何选项什么以往任何时候都在以前相同的选项启用的选项应保护后可用。
1条答案
按热度按时间bvhaajcl1#
要在保护工作表时启用预期功能,请相应指定相关参数。
Microsoft参考文档:
Worksheet.Protect method (Excel)