Password Macro help

Closed
tinamc Posts 1 Registration date Friday March 15, 2013 Status Member Last seen March 15, 2013 - Mar 15, 2013 at 04:42 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Mar 16, 2013 at 07:24 AM
Hello,

I have a code that unlocks sheets I need to use that are password protected but I have other code I used to combine the worksheets into 1 workbook. Otherwise I would have to open each sheet and there are 50 per folder and 10 folders per quarter. Lots of opening and tons of work and typing. So I have a macro that moves all the sheets into 1 workbook. I end up with 4 workbooks cuz I have 4 quarters. But then I have all these sheets that are password protected. The code I run is:

'Entry point for RibbonX button click
Sub ShowATPDialog(control As IRibbonControl)
Application.Run ("fDialog")
End Sub

'Callback for RibbonX button label
Sub GetATPLabel(control As IRibbonControl, ByRef label)
label = ThisWorkbook.Sheets("RES").Range("A10").Value
End Sub

Sub Password()
'

Dim v1 As Integer, u1 As Integer, w1 As Integer
Dim v2 As Integer, u2 As Integer, w2 As Integer
Dim v3 As Integer, u3 As Integer, w3 As Integer
Dim v4 As Integer, u4 As Integer, w4 As Integer
On Error Resume Next

For v1 = 65 To 66: For u1 = 65 To 66: For w1 = 65 To 66
For v2 = 65 To 66: For u2 = 65 To 66: For w2 = 65 To 66
For v3 = 65 To 66: For u3 = 65 To 66: For w3 = 65 To 66
For v4 = 65 To 66: For u4 = 65 To 66: For w4 = 32 To 126


ActiveSheet.Unprotect Chr(v1) & Chr(u1) & Chr(w1) & _
Chr(v2) & Chr(u2) & Chr(v3) & Chr(u3) & Chr(w3) & _
Chr(v4) & Chr(u4) & Chr(w4) & Chr(w2)
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next

End Sub



I do this per sheet with ctl p but would really like to figure out how to tweek this code to have it run for all sheets at one time. I tried selecting all sheets so they are highlighted but that did not work

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Mar 16, 2013 at 07:24 AM
My question would be why brute hack of password if you are owner of workbook. You could have provided the password rather using this tech ?
1