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
MsgBox ("Пароль: " & txt$ & Chr(N))
UnlockSheet = True
Exit Function
End If
Next
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next
End Function

 

Реклама