Unlock Excel table

The code below can unlock a workbook password and sheet passwords. To use it, copy it to a new general code module.<!--break--> To unlock a workbook password, activate the workbook to be unlocked and run the macro $$$UnlockWorkbook$$$

To unlock a sheet, activate the sheet and run the macro $$$UnlockSheet$$$

<pre>
' modUnlockRoutines
'
' Module provides Excel workbook and sheet unlock routines. The algorithm
' relies on a backdoor password that can be 1 to 9 characters long where each
' character is either an "A" or "B" except the last which can be any character
' from ASCII code 32 to 255.
'
' Implemented as a regular module for use with any Excel VBA project.
'
' Dependencies:
'
' None
'
' © 2007 Kevin M. Jones

Option Explicit

Private Sub DisplayStatus( _
ByVal PasswordsTried As Long _
)

' Display the status in the Excel status bar.
'
' Syntax
'
' DisplayStatus(PasswordsTried)
'
' PasswordsTried - The number of passwords tried thus far.

Static LastStatus As String

LastStatus = Format(PasswordsTried / 57120, "0%") & " of possible passwords tried."
If Application.StatusBar <> LastStatus Then
Application.StatusBar = LastStatus
DoEvents
End If

End Sub

Private Function TrySheetPasswordSize( _
ByVal Size As Long, _
ByRef PasswordsTried As Long, _
ByRef Password As String, _
Optional ByVal Base As String _
) As Boolean

' Try unlocking the sheet with all passwords of the specified size.
'
' TrySheetPasswordSize(Size, PasswordsTried, Password, [Base])
'
' Size - The size of the password to try.
'
' PasswordsTried - The cummulative number of passwords tried thus far.
'
' Password - The current password.
'
' Base - The base password from the calling routine.

Dim Index As Long

On Error Resume Next
If IsMissing(Base) Then Base = vbNullString
If Len(Base) < Size - 1 Then
For Index = 65 To 66
If TrySheetPasswordSize(Size, PasswordsTried, Password, Base & Chr(Index)) Then
TrySheetPasswordSize = True
Exit Function
End If
Next Index
ElseIf Len(Base) < Size Then
For Index = 32 To 255
ActiveSheet.Unprotect Base & Chr(Index)
If Not ActiveSheet.ProtectContents Then
TrySheetPasswordSize = True
Password = Base & Chr(Index)
Exit Function
End If
PasswordsTried = PasswordsTried + 1
Next Index
End If
On Error GoTo 0

DisplayStatus PasswordsTried

End Function

Private Function TryWorkbookPasswordSize( _
ByVal Size As Long, _
ByRef PasswordsTried As Long, _
ByRef Password As String, _
Optional ByVal Base As String _
) As Boolean

' Try unlocking the workbook with all passwords of the specified size.
'
' TryWorkbookPasswordSize(Size, PasswordsTried, Password, [Base])
'
' Size - The size of the password to try.
'
' PasswordsTried - The cummulative number of passwords tried thus far.
'
' Password - The current password.
'
' Base - The base password from the calling routine.

Dim Index As Long

On Error Resume Next
If IsMissing(Base) Then Base = vbNullString
If Len(Base) < Size - 1 Then
For Index = 65 To 66
If TryWorkbookPasswordSize(Size, PasswordsTried, Password, Base & Chr(Index)) Then
TryWorkbookPasswordSize = True
Exit Function
End If
Next Index
ElseIf Len(Base) < Size Then
For Index = 32 To 255
ActiveWorkbook.Unprotect Base & Chr(Index)
If Not ActiveWorkbook.ProtectStructure And Not ActiveWorkbook.ProtectWindows Then
TryWorkbookPasswordSize = True
Password = Base & Chr(Index)
Exit Function
End If
PasswordsTried = PasswordsTried + 1
Next Index
End If
On Error GoTo 0

DisplayStatus PasswordsTried

End Function

Public Sub UnlockSheet()

' Unlock the active sheet using a backdoor Excel provides where an alternate
' password is created that is more limited.

Dim PasswordSize As Variant
Dim PasswordsTried As Long
Dim Password As String

PasswordsTried = 0
If Not ActiveSheet.ProtectContents Then
MsgBox "The sheet is already unprotected."
Exit Sub
End If
On Error Resume Next
ActiveSheet.Protect ""
ActiveSheet.Unprotect ""
On Error GoTo 0
If ActiveSheet.ProtectContents Then
For Each PasswordSize In Array(5, 4, 6, 7, 8, 3, 2, 1)
If TrySheetPasswordSize(PasswordSize, PasswordsTried, Password) Then Exit For
Next PasswordSize
End If
If Not ActiveSheet.ProtectContents Then
MsgBox "The sheet " & ActiveSheet.Name & " has been unprotected with password '" & Password & "'."
End If
Application.StatusBar = False

End Sub

Public Sub UnlockWorkbook()

' Unlock the active workbook using a backdoor Excel provides where an alternate
' password is created that is more limited.

Dim PasswordSize As Variant
Dim PasswordsTried As Long
Dim Password As String

PasswordsTried = 0
If Not ActiveWorkbook.ProtectStructure And Not ActiveWorkbook.ProtectWindows Then
MsgBox "The workbook is already unprotected."
Exit Sub
End If
On Error Resume Next
ActiveWorkbook.Unprotect vbNullString
On Error GoTo 0
If ActiveWorkbook.ProtectStructure Or ActiveWorkbook.ProtectWindows Then
For Each PasswordSize In Array(5, 4, 6, 7, 8, 3, 2, 1)
If TryWorkbookPasswordSize(PasswordSize, PasswordsTried, Password) Then Exit For
Next PasswordSize
End If
If Not ActiveWorkbook.ProtectStructure And Not ActiveWorkbook.ProtectWindows Then
MsgBox "The workbook " & ActiveWorkbook.Name & " has been unprotected with password '" & Password & "'."
End If
Application.StatusBar = False

End Sub
</pre>

Source http://www.zorvek.com/excel/unlocking-workbooks-and-sheets.htm

OS
Windows
Product
MS Excel (2002, ..)

Comments

Submitted by writed on Mon, 01/28/2013 - 11:04

Permalink

surgical treatment could be reversed, in the event the client needs to perform so afterwards. The middle for web page provides a number of movies of surgical treatment. A potential individual is essential to look at them just before choosing to go in advance with it. You could possibly also pay money for the middle for laparoscopic being overweight operation affected person guide evening dresses for short women evening dresses for short women , evening dresses evening dresses which can offer you with every one of the information you"ll want relating to operation, technique, software kind and fees. Does one possess a need to?Many people do, specially today, although not many individuals understand that earning dollars at home could be the greatest strategy to modify your complete lifestyle. There are several methods that everybody s daily life will transform any time you start off a company at home and start generating an cash flow with it. You will need to be aware of the various approaches your lifetime will alter so you"re able to see why starting a property organization is exactly what a lot of people just about everywhere are deciding on to perform. Listed here would be the lifetime adjustments which you are likely to expertise whenever you can make an revenue at your home out of your very own small business. One particular: No much more manager You"ll not need to get the job done to get a manager any longer as you are likely to turn out to be the manager. summer dresses summer dresses That could be a large modify for most individuals, particularly if you"ve labored your complete daily life for somebody else. Two cheap plus size bridesmaid dresses cheap plus size bridesmaid dresses : Economic independence is inside your arrive at You will discover not a lot of people that understand that creating an money by using a company of your respective individual at home could be the most basic and finest way for reaching the money independence you"ve usually dreamed of. You currently being the manager within your organization receives to also pick the number of earnings you might make with it. The greater operate you place into making your enterprise right up until it"s prosperous the greater dollars you are going to make with it and anyone can effortlessly make ample cash flow to own the economic flexibility you constantly wished to own flower girl dresses flower girl dresses . A few: A lot more liberty inside your daily life You will discover most likely several issues you may need to complete as part of your times, but doing work a career isn"t going to allow you to provide the totally free time and energy to do them, appropriate?This can be a

Submitted by writed on Mon, 02/04/2013 - 09:53

Permalink

colored illustrations, or glassine envelopes that contains all of the info with the working day sealed that has a festive pop of crimson washi tape that peeks by the paper supplying a tempting perception regarding what on earth is contained within. Irrespective of whatever you may well consider, there exists however a large alternative of blossoms even for wintertime wedding ceremonies, so overlook weighty crimson roses and communicate in your florist about lighter in weight choices white bridesmaid dresses white bridesmaid dresses , tulips flower girl dresses macys flower girl dresses macys , lilies and anemones really are a fantastic modern alternative. Present your company festive favours white evening dresses white evening dresses mother of bride dresses mother of bride dresses , fantastically wrapped presents with your color palette carry the table decoration, and in any case opening offers provides out the kid in all of people!Have you been acquiring married about the Seasonal interval? How have you been incorporating a