You are on page 1of 17

DESBLOQUEAR PLANILHA

O primeiro modo atravs de macro. Voc precisa entender um pouco de macro ou pelo
menos ler este post, onde explico como criar uma macro simples.
Na verdade voc precisar apenas pressionar Alt + F11 para abrir o Visual Basic, que
quem gerencia as macros do Excel. Em seguida voc ir clicar duas vezes no item que
tem fundo azul na imagem abaixo:: (Esta_pasta_de_trabalho):

<img
class="aligncenter
size-full
wp-image-1642"
src="http://www.feranoexcel.com/wp-content/uploads/Esta-pasta-de-trabalho.jpg" alt="Esta
pasta de trabalho" width="182" height="178" />
Ao fazer isto, ser aberto do lado direito um painel. Voc ir ento copiar e colar o cdigo
abaixo:
Sub DesprotegerPlanilhaAtiva()
Dim i, i1, i2, i3, i4, i5, i6 As Integer, j As Integer, k As Integer, l As Integer , m As
Integer, n As Integer
On Error Resume Next
For i = 65 To 66
For j = 65 To 66
For k = 65 To 66
For l = 65 To 66
For m = 65 To 66
For i1 = 65 To 66
For i2 = 65 To 66
For i3 = 65 To 66
For i4 = 65 To 66
For i5 = 65 To 66
For i6 = 65 To 66
For n = 32 To 126
ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & Chr(l) & Chr(m) & Chr (i1) & Chr(i2)
& Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
If ActiveSheet.ProtectContents = False Then
MsgBox Planilha desprotegida com sucesso!!!
Exit Sub
End If
Next

Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
End Sub
Aps colar o cdigo ele ficar mais ou menos assim:

<img class="aligncenter size-full wp-image-1643" src="http://www.feranoexcel.com/wpcontent/uploads/copiando-codigo-da-macro.jpg"


alt="copiando
cdigo
da
macro"
width="671" height="321" />
Feito isso, pode fechar o Visual Basic. Agora selecione a planilha que voc deseja
desbloquear (clique sobre o nome dela). Em seguida v at a guia Exibio, item Macros.
Voc ver que aparecer uma macro com nome DesprotegerPlanilhaAtiva:

<img
class="aligncenter
size-full wp-image-1644" src="http://www.feranoexcel.com/wp-content/uploads/excutarmacro-para-desproteger-planilha.jpg" alt="executar macro para desproteger planilha"
width="390" height="371" />
Clique sobre o boto Executar e aguarde alguns segundos. Se tudo deu certo, voc ver a
mensagem abaixo:

<img class="aligncenter size-full wp-image-1645"


src="http://www.feranoexcel.com/wp-content/uploads/planilha-desprotegida-comsucesso.jpg" alt="planilha desprotegida com sucesso" width="259" height="156" />
Caso voc precise desbloquear mais de uma planilha, voc ter que fazer este processo
uma a uma. Se preferir, voc pode voltar janela de Macros e criar uma tecla de atalho.
Para isso, v at o boto Opes dentro da janela e defina a sua tecla de atalho preferida.
UPDATE: muitos leitores entraram em contato dizendo que o cdigo mencionado
acima d erro na linha em vermelho abaixo:

<img class="aligncenter
size-full wp-image-2053" src="http://www.feranoexcel.com/wp-content/uploads/erro-codigo-

macro-desproteger-planilha.jpg" alt="erro codigo macro desproteger planilha" width="413"


height="84" />
Caso isto acontea com voc, bem simples de resolver: que por algum motivo,
que no sei dizer qual, o Excel no cola as aspas de maneira correta. Voc s
precisa apagar as aspas e digit-las novamente. Faa o teste e deixe comentrio
dizendo se deu certo ou no.
Obs: a partir da verso 2007, documentos que contenham macros devem ser salvos em
um formato especfico, chamado Pasta de Trabalho habilitada para macro do Excel,
cuja extenso .xlsm. Se voc tentar salvar neste momento, aparecer uma janela
avisando sobre este fato. Voc ter duas opes neste caso: a primeira clicar em No e
escolher o formato habilitado para macros do Excel. A segunda voltar ao Visual Basic e
excluir todo cdigo. Assim voc poder salvar normalmente.

DESBLOQUEAR PLANILHA E ABA EXCEL WORKSHEET


O cdigo abaixo pode desbloquear uma senha pasta de trabalho e senhas de folha. Para us-lo, copi-lo para um novo
mdulo de cdigo geral. Para desbloquear uma senha pasta de trabalho, activar o livro a ser desbloqueado e executar
a macro:
UnlockWorkbook
Para desbloquear uma folha, ativar a folha e executar a macro:
UnlockSheet
O cdigo segue abaixo.
'modUnlockRoutines
'
'Module fornece livro do Excel e rotinas de folha de desbloqueio. O algoritmo
'Depende de uma senha backdoor que pode ser 1-9 caracteres onde cada
"Carter ou um" A "ou" B ", exceto a ltima que pode ser qualquer personagem
'Do cdigo ASCII 32-255.
'
'Implementado como um mdulo regular para uso com qualquer projeto Excel VBA.
'
'Dependncias:
'
'

Nenhum

CODIGO

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

You might also like