Excel密码怎么破解?有密码怎么取消保护?
Excel文件设了密码却忘了咋整?别慌,这儿有两种破解法子呢,赶紧来看看!
方法一,要是咱们有密码,能直接在打开的excel里找“工具”――》“保护”――》“撤消工作簿保护”,在弹出窗口输密码就行啦。
方法二,要是没密码,咱们能靠“宏模块”来破解,下面一起瞧瞧具体步骤哈。
1、先打开要处理的excel文件,然后按“ALT”+“F11” ,如下图所示。
2、接着点击菜单上的“插入”――“模块”,如图所示。
3、把下面的代码复制粘贴到空白区域;
代码如下
复制代码
Public Sub AllInternalPasswords()
' Breaks worksheet and workbook structure passwords. Bob McCormick
' probably originator of base code algorithm modified for coverage
' of workbook structure / windows passwords and for multiple passwords
'
' Norman Harker and JE McGimpsey 27-Dec-2002 (Version 1.1)
' Modified 2003-Apr-04 by JEM: All msgs to constants, and
' eliminate one Exit Sub (Version 1.1.1)
' Reveals hashed passwords NOT original passwords
Const DBLSPACE As String=vbNewLine & vbNewLine
Const AUTHORS As String=DBLSPACE & vbNewLine & _
"Adapted from Bob McCormick base code by" & _
"Norman Harker and JE McGimpsey"
Const HEADER As String="AllInternalPasswords User Message"
Const VERSION As String=DBLSPACE & "Version 1.1.1 2003-Apr-04"
Const REPBACK As String=DBLSPACE & "Please report failure " & _
"to the microsoft.public.excel.programming newsgroup."
Const ALLCLEAR As String=DBLSPACE & "The workbook should " & _
"now be free of all password protection, so make sure you:" & _
DBLSPACE & "SAVE IT NOW!" & DBLSPACE & "and also" & _
DBLSPACE & "BACKUP!, BACKUP!!, BACKUP!!!" & _
DBLSPACE & "Also, remember that the password was " & _
"put there for a reason. Don't stuff up crucial formulas " & _
"or data." & DBLSPACE & "Access and use of some data " & _
"may be an offense. If in doubt, don't."
Const MSGNOPWORDS1 As String="There were no passwords on " & _
"sheets, or workbook structure or windows." & AUTHORS & VERSION
Const MSGNOPWORDS2 As String="There was no protection to " & _
"workbook structure or windows." & DBLSPACE & _
"Proceeding to unprotect sheets." & AUTHORS & VERSION
Const MSGTAKETIME As String="After pressing OK button this " & _
"will take some time." & DBLSPACE & "Amount of time " & _
"depends on how many different passwords, the " & _
"passwords, and your computer's specification." & DBLSPACE & _
"Just be patient! Make me a coffee!" & AUTHORS & VERSION
Const MSGPWORDFOUND1 As String="You had a Worksheet " & _
"Structure or Windows Password set." & DBLSPACE & _
"The password found was: " & DBLSPACE & "
&\#x22; &\#x26; DBLSPACE &\#x26; _&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x22;Note it down for potential future use in other workbooks by &\#x22; &\#x26; _&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x22;the same person who set this password.&\#x22; &\#x26; DBLSPACE &\#x26; _&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x22;Now to check and clear other passwords.&\#x22; &\#x26; AUTHORS &\#x26; VERSION&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Const MSGPWORDFOUND2 As String=&\#x22;You had a Worksheet &\#x22; &\#x26; _&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x22;password set.&\#x22; &\#x26; DBLSPACE &\#x26; &\#x22;The password found was: &\#x22; &\#x26; _&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;DBLSPACE &\#x26; &\#x22;
"future use in other workbooks by same person who " & _
"set this password." & DBLSPACE & "Now to check and clear " & _
"other passwords." & AUTHORS & VERSION
Const MSGONLYONE As String="Only structure / windows " & _
"protected with the password that was just found." & _
ALLCLEAR & AUTHORS & VERSION & REPBACK
Dim w1 As Worksheet, w2 As Worksheet
Dim i As Integer, j As Integer, k As Integer, l As Integer
Dim m As Integer, n As Integer, i1 As Integer, i2 As Integer
Dim i3 As Integer, i4 As Integer, i5 As Integer, i6 As Integer
Dim PWord1 As String
Dim ShTag As Boolean, WinTag As Boolean
Application.ScreenUpdating=False
With ActiveWorkbook
WinTag=.ProtectStructure Or .ProtectWindows
End With
ShTag=False
For Each w1 In Worksheets
ShTag=ShTag Or w1.ProtectContents
Next w1
If Not ShTag And Not WinTag Then
MsgBox MSGNOPWORDS1, vbInformation, HEADER
Exit Sub
End If
MsgBox MSGTAKETIME, vbInformation, HEADER
If Not WinTag Then
MsgBox MSGNOPWORDS2, vbInformation, HEADER
Else
On Error Resume Next
Do 'dummy do loop
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
With ActiveWorkbook
.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 .ProtectStructure=False And _
.ProtectWindows=False Then
PWord1=Chr(i) & Chr(j) & Chr(k) & Chr(l) & _
Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
MsgBox Application.Substitute(MSGPWORDFOUND1, _
"
&\#x22;, PWord1), vbInformation, HEADER&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Exit Do &\#x27;Bypass all for...nexts&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;End If&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;End With&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Next: Next: Next: Next: Next: Next&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Next: Next: Next: Next: Next: Next&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Loop Until True&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;On Error GoTo 0&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;End If&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;If WinTag And Not ShTag Then&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;MsgBox MSGONLYONE, vbInformation, HEADER&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Exit Sub&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;End If&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;On Error Resume Next&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For Each w1 In Worksheets&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x27;Attempt clearance with PWord1&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;w1.Unprotect PWord1&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Next w1&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;On Error GoTo 0&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;ShTag=False&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For Each w1 In Worksheets&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x27;Checks for all clear ShTag triggered to 1 if not.&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;ShTag=ShTag Or w1.ProtectContents&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Next w1&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;If ShTag Then&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For Each w1 In Worksheets&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;With w1&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;If .ProtectContents Then&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;On Error Resume Next&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Do &\#x27;Dummy do loop&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For i=65 To 66: For j=65 To 66: For k=65 To 66&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For l=65 To 66: For m=65 To 66: For i1=65 To 66&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For i2=65 To 66: For i3=65 To 66: For i4=65 To 66&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For i5=65 To 66: For i6=65 To 66: For n=32 To 126&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;.Unprotect Chr(i) &\#x26; Chr(j) &\#x26; Chr(k) &\#x26; _&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Chr(l) &\#x26; Chr(m) &\#x26; Chr(i1) &\#x26; Chr(i2) &\#x26; Chr(i3) &\#x26; _&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Chr(i4) &\#x26; Chr(i5) &\#x26; Chr(i6) &\#x26; Chr(n)&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;If Not .ProtectContents Then&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;PWord1=Chr(i) &\#x26; Chr(j) &\#x26; Chr(k) &\#x26; Chr(l) &\#x26; _&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Chr(m) &\#x26; Chr(i1) &\#x26; Chr(i2) &\#x26; Chr(i3) &\#x26; _&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Chr(i4) &\#x26; Chr(i5) &\#x26; Chr(i6) &\#x26; Chr(n)&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;MsgBox Application.Substitute(MSGPWORDFOUND2, _&\#x3C;/p&\#x3E; &\#x3010;&\#x6539;&\#x5199;&\#x5F00;&\#x59CB;&\#x3011; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x22;
'leverage finding Pword by trying on other sheets
For Each w2 In Worksheets
w2.Unprotect PWord1
Next w2
Exit Do 'Bypass all for...nexts
End If
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
Loop Until True
On Error GoTo 0
End If
End With
Next w1
End If
MsgBox ALLCLEAR & AUTHORS & VERSION & REPBACK, vbInformation, HEADER
End Sub
4、确定没问题后,按“F5”运行宏模块进行密码破解,先点击确定,之后就能看到图中红框处的密码数字啦
5、完成之后再试着编辑excel,就不会有任何问题咯,你也赶紧去试试吧!