I have been working in a spreadsheet that contains confidential information. I password protected so the user would need to enter a password to open the file. I have forgotten the password. Is there away around this problem?
Thanks
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Passwords
Deborah,
Microsoft never claimed that the password protection of their spreadsheets was bulletproof (if this is the correct word in English for this). You can write your own code to unprotect your spreadsheet (that doesn’t mean that you’ll obtain the password, but the problem is solved anyhow). I add some code that I wrote to experiment with unprotecting the active spreadsheet. The code is limited in the sense that it has to be adapted if the password has more than 5 characters. What the code does is actually very simple: it tries all kind of combinations, trying to unprotect the sheet.
Sub Cracker()
Dim h As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim pwd As String
Dim tijd, delay
tijd = Time
Application.StatusBar = Format$(Time – tijd, “hh:mm:ss”)
‘1 kar
For l = 32 To 255
pwd = Chr$(l)
On Error Resume Next
ActiveSheet.Unprotect (pwd)
If Err = 0 Then
MsgBox “Spreadsheet unprotected”
On Error GoTo 0
Exit Sub
Else
On Error GoTo 0
End If
Next l
Application.StatusBar = Format$(Time – tijd, “hh:mm:ss”)
‘2 kar
For k = 2 To 1 Step -1
Application.StatusBar = Format$(Time – tijd, “hh:mm:ss”)
For l = 32 To 96
pwd = Chr$(k) & Chr$(l)
On Error Resume Next
ActiveSheet.Unprotect (pwd)
If Err = 0 Then
MsgBox “Spreadsheet unprotected”
On Error GoTo 0
Exit Sub
Else
On Error GoTo 0
End If
Next l
Next k
‘3 kar
For j = 2 To 1 Step -1
For k = 2 To 1 Step -1
Application.StatusBar = Format$(Time – tijd, “hh:mm:ss”)
For l = 32 To 96
pwd = Chr$(j) & Chr$(k) & Chr$(l)
On Error Resume Next
ActiveSheet.Unprotect (pwd)
If Err = 0 Then
MsgBox “Spreadsheet unprotected”
On Error GoTo 0
Exit Sub
Else
On Error GoTo 0
End If
Next l
Next k
Next j
‘4 kar
For i = 2 To 1 Step -1
For j = 2 To 1 Step -1
For k = 2 To 1 Step -1
Application.StatusBar = Format$(Time – tijd, “hh:mm:ss”)
For l = 32 To 96
pwd = Chr$(i) & Chr$(j) & Chr$(k) & Chr$(l)
On Error Resume Next
ActiveSheet.Unprotect (pwd)
If Err = 0 Then
MsgBox “Spreadsheet unprotected”
On Error GoTo 0
Exit Sub
Else
On Error GoTo 0
End If
Next l
Next k
Next j
Next i
‘5 kar
For h = 2 To 1 Step -1
For i = 2 To 1 Step -1
For j = 2 To 1 Step -1
For k = 2 To 1 Step -1
Application.StatusBar = Format$(Time – tijd, “hh:mm:ss”)
For l = 32 To 96
pwd = Chr$(h) & Chr$(i) & Chr$(j) & Chr$(k) & Chr$(l)
On Error Resume Next
ActiveSheet.Unprotect (pwd)
If Err = 0 Then
MsgBox “Spreadsheet unprotected”
On Error GoTo 0
Exit Sub
Else
On Error GoTo 0
End If
Next l
Next k
Next j
Next i
Next h
Application.StatusBar = “”
End Sub
Password crackers are available (for money) at
http://www.LostPassword.com [/url]
From an advert in Woody’s Office Watch
Deborah,
I see that you’ve got some interesting suggestions from other people. You can indeed find all kind of cracker software for Excel spreadsheets and add-ins on the web. The code that I gave to you can simply be pasted into a module and then from the Excel >> Tools >> Macro menu be run. There is not danger of anything. If it takes too long just interrupt it by using ctrl break. The only thing the code does is making a password, try to unprotect the sheet with that password, if not successful, a new password is tried out etc., until the spreadsheet is unprotected.
There is a difference between worksheet/workbook protection and “open the file” passwording. Protection is basically to eanble you to stop yourself or users from doing things you don’t want to, either accidentally or on purpose, whereas “open” passwording a workbook either prevents access or stops you saving over the active copy. Because protection can utilise passwords, the two can become confused.
I have some home-grown code that is similar to Hans’ but goes for the “Open” password as opposed to the protection password but it is very slow so I won’t post it. However, he does build his password string differently to mine and that may speed things up. If you’re prepared to spend money then the link above – or any mentioned at j-walk should get you on your way.
Brooke
Steven,
As Brooke said, my code works only for open workbooks with protected worksheets. You need to buy a password cracker if you want to recover your workbook. Some of these crackers have trial versions which allow you to find the first three characters of your password. Maybe this is sufficient for you to remember the whole password. Have a look at the websites mentioned in this thread.
It’s quite a while ago that I wrote this code. Excel has a strange way to deal with passwords. Actually, your spreadsheet password is not unique. There are many other passwords (with the same length, that’s important) that will unprotect your spreadsheet. My code does not discover your password, but will unprotect the sheet. The ‘other’ passwords may also contain control characters. I discovered via trial-and-error that the execution time could be shortened by restricting to the combinations that are actually in the code. I can’t remember why I used “2 to 1”, maybe it’ll work with “1 to 2”. Just try it out, byt protecting a sheet with a small e.g. 4-letter password, run the code and see if it is possible to unprotect the sheet.
For a free add-in that can find lost passwords for excel (but not vba modules) try this site from Erlandsen Data Consulting.
http://www.erlandsendata.no/english/downloads/tools.htm
Tony
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.