Макрос для снятия защиты листа или книги Excel

Sub Unlock_Excel_Worksheet() t = Timer If UnlockSheet(ActiveSheet) Then MsgBox "Защита снята. Потребовалось времени: " & Format(Timer - t, "0.0 сек.") Else MsgBox "Не удалось снять защиту листа", vbCritical End If End Sub
Function UnlockSheet(ByRef sh As Worksheet) As Boolean Dim i%, j%, k%, l%, m%, n As Long, i1%, i2%, i3%, i4%, i5%, i6%, txt$ On Error Resume Next For i = 65 To 66: For j = 65 To 66: For k = 65 To 66 For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66 For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66 For i5 = 65 To 66: For i6 = 65 To 66 txt$ = Chr(i) & Chr(j) & Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) For n = 32 To 126 sh.Unprotect txt$ & Chr(n) If Err Then Err.Clear Else Debug.Print "Пароль: " & txt$ & Chr(n) UnlockSheet = True Exit Function End If Next Next: Next: Next: Next: Next: Next Next: Next: Next: Next: Next End Function

Снимает защиту книги Excel

Sub Unlock_Excel_Workbook() ' снятие защиты книги Excel t = Timer If UnlockWorkbook(ActiveWorkbook) Then MsgBox "Защита снята. Потребовалось времени: " & Format(Timer - t, "0.0 сек.") Else MsgBox "Не удалось снять защиту книги", vbCritical End If End Sub
Function UnlockWorkbook(ByRef wb As Workbook) As Boolean Dim i%, j%, k%, l%, m%, n As Long, i1%, i2%, i3%, i4%, i5%, i6%, txt$ On Error Resume Next For i = 65 To 66: For j = 65 To 66: For k = 65 To 66 For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66 For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66 For i5 = 65 To 66: For i6 = 65 To 66 txt$ = Chr(i) & Chr(j) & Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) For n = 32 To 126 wb.Unprotect txt$ & Chr(n) If Err Then Err.Clear Else Debug.Print "Пароль: " & txt$ & Chr(n) UnlockWorkbook = True Exit Function End If Next Next: Next: Next: Next: Next: Next Next: Next: Next: Next: Next End Function