AW: Das ist die perfekte Erklärung...
tobias
Hallo
der Vollständigkeit halber und weils sowieso kein Geheimnis ist:
Die Blattschutz-Passwörter werden Excel-Intern in einer 11-stelligen Kombination aus A und B sowie einem ASCII-Zeichen gespeichert. Dabei entstehen 2047 A,B Kombinationen
Sub RemovePassword(Mappe As String, Blatt As String)
Dim count As Integer, CIndex As Integer, PWord As String
On Error Resume Next
For count = 0 To 2047
PWord = FindPassword(count)
For CIndex = 32 To 126
Err.Clear
Workbooks(Mappe).Worksheets(Blatt).Unprotect PWord & Chr(CIndex)
If Err = 0 Then
Exit Sub
End If
Next
Next
End Sub
Function FindPassword(Zahl As Integer) As String
Dim Result As String, Index As Integer
On Error Resume Next
Index = Zahl
While Index > 0
If Index Mod 2 = 0 Then
Result = "A" & Result
Else
Result = "B" & Result
End If
Index = Index \ 2
Wend
While Len(Result) < 11
Result = "A" & Result
Wend
FindPassword = Result
End Function
mfg tobias