GetPassword.vba 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. Sub GetPassword()
  2. 'Author unknown but submitted by brettdj of www.experts-exchange.com
  3. Dim i As Integer, j As Integer, k As Integer
  4. Dim l As Integer, m As Integer, n As Integer
  5. Dim i1 As Integer, i2 As Integer, i3 As Integer
  6. Dim i4 As Integer, i5 As Integer, i6 As Integer
  7. On Error Resume Next
  8. For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
  9. For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
  10. For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
  11. For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
  12. ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & _
  13. Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
  14. Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
  15. If ActiveSheet.ProtectContents = False Then
  16. MsgBox "One usable password is " & Chr(i) & Chr(j) & _
  17. Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
  18. Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
  19. ActiveWorkbook.Sheets(1).Select
  20. Range("a1").FormulaR1C1 = Chr(i) & Chr(j) & _
  21. Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
  22. Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
  23. Exit Sub
  24. End If
  25. Next: Next: Next: Next: Next: Next
  26. Next: Next: Next: Next: Next: Next
  27. End Sub