Tested in Excel 365 (16.8730.2046) 64-bit
This is NOT a code to hack passwords! It simply uses a list of known passwords to unlock all sheets in a file.
- Public Sub MakeVisibleRemovePass(PassArray As String)
- ' PassArray is a string of known passwords delimited by space
- ' assuming that passwords do not contain spaces
- Dim i, j
- Dim myPassArray
- myPassArray = Split(PassArray, " ")
- On Error GoTo err_check
- For i = 1 To Sheets.Count
- Debug.Print Sheets(i).Name
- If Not Sheets(i).Visible Then Sheets(i).Visible = True
- If Sheets(i).ProtectContents Then
- For j = 0 To UBound(myPassArray)
- Sheets(i).Unprotect Password:=myPassArray(j)
- Next j
- End If
- Next i
- exit_sub:
- Exit Sub
- err_check:
- Debug.Print "eroare"
- Resume Next
- End Sub
- ' use it like this:
- Sub main()
- Call MakeVisibleRemovePass("pass1 pass2 pass3 smth1 smth2 $%A*")
- End Sub