If you know what the password is, go ahead and open the Excel document. Then click on File > Save As. To the left of the Save button is a little drop down labeled Tools. Click on that, and then click on General Options. Delete the password entries there, and click OK. Save the document.
If you do not know what the password is, you can use VBA to find it. If I had to take a guess, your user probably didn't use a super strong password, so we could use a brute force type method to find it. The code below is rough, but it has helped me find a weak, lost password on several of my users' documents. It checks for passwords of any length with the ASCII characters from 1 to z. You would call it from the Immediate Window and wait several minutes like so:
? GetPassword("D:\mywkbk.xlsx")
-
Public Function GetPassword(ByRef sFileName As String) As String
On Error Resume Next
Dim pw As String
pw = ""
Do
VBA.Err.Clear
pw = GenerateNextPassword(pw)
Application.Workbooks.Open sFileName, False, True, , pw, pw
VBA.DoEvents
Loop While VBA.Err.Number = 5408
GetPassword = pw
End Function
Public Function GenerateNextPassword(ByRef sCurrentPassword As String) As String
Const MAX_CHAR = 122
Const MIN_CHAR = 49
Dim sCurrentPasswordMax As String
Dim sNewPassword As String
Dim i As Long
sCurrentPasswordMax = String(Len(sCurrentPassword), Chr(MAX_CHAR))
If sCurrentPassword = sCurrentPasswordMax Then
'do an increment that changes the length
sNewPassword = String(Len(sCurrentPassword) + 1, Chr(MIN_CHAR))
Debug.Print Now(); ": "; sNewPassword
ElseIf Asc(Right(sCurrentPassword, 1)) = MAX_CHAR Then
'do an increment that changes multiple characters
sNewPassword = Left(sCurrentPassword, Len(sCurrentPassword) - 1) & Chr(MIN_CHAR)
For i = Len(sCurrentPassword) - 1 To 1 Step -1
sNewPassword = Left(sNewPassword, i - 1) & Chr(Asc(Mid(sNewPassword, i, 1)) + 1) & Mid(sNewPassword, i + 1)
If Asc(Mid(sCurrentPassword, i, 1)) <> MAX_CHAR Then
Exit For
End If
Next i
Else
'do an increment on the rightmost character
sNewPassword = Left(sCurrentPassword, Len(sCurrentPassword) - 1) & Chr(Asc(Right(sCurrentPassword, 1)) + 1)
End If
GenerateNextPassword = sNewPassword
End Function
the excel .xlsx file is actually just a zip file. unzip and follow instructions such as these. have tried in past not sure if it works if whole file is password protected though. http://nileshkumar83.blogspot.com/2012/05/breaking-excel-password-protection.html
– Joop – 2014-10-01T12:41:39.9831
@SamuelJaeschke The hook method at https://stackoverflow.com/a/27508116/5757159 works every time. No cracking required.
– ThunderFrame – 2017-07-26T06:47:28.987Um, you're kinda stuffed. Unless you want to do complicated cryptography stuff... (I'm not aware of any programs for doing this on .xls). There's no normal, automated way of doing this in Excel - that would kind-of defeat the point of having a password in the first place... your only hope would be a special cipher cracking program for such files (which may be hard to find). Maybe Google
decrypt xls
or something similar. – Samuel Jaeschke – 2009-10-21T10:06:32.313