Make sheets visible and remove passwords

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.

 
 
  1. Public Sub MakeVisibleRemovePass(PassArray As String)
  2. ' PassArray is a string of known passwords delimited by space
  3. ' assuming that passwords do not contain spaces
  4.    Dim i, j
  5.     Dim myPassArray
  6.    
  7.     myPassArray = Split(PassArray, " ")
  8.     On Error GoTo err_check
  9.    
  10.     For i = 1 To Sheets.Count
  11.         Debug.Print Sheets(i).Name
  12.         If Not Sheets(i).Visible Then Sheets(i).Visible = True
  13.         If Sheets(i).ProtectContents Then
  14.             For j = 0 To UBound(myPassArray)
  15.                 Sheets(i).Unprotect Password:=myPassArray(j)
  16.             Next j
  17.         End If
  18.     Next i
  19.    
  20. exit_sub:
  21.     Exit Sub
  22. err_check:
  23.     Debug.Print "eroare"
  24.     Resume Next
  25.    
  26. End Sub
  27. ' use it like this:
  28. Sub main()
  29.     Call MakeVisibleRemovePass("pass1 pass2 pass3 smth1 smth2 $%A*")
  30. End Sub

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.