Excel撤销工作表保护密码办法_Excel怎么撤销工作表
我们经常使用Excel的工作表保护功能,将工作表用密码保护起来,以防别人操作时进行修改,这样一来有可能会无法进行一些操作(如输入公式等),时间久了保护的密码也有可能忘记了,这该怎么办呢?只要按照以下步骤操作,Excel工作表保护密码瞬间即破!
1、打开您需要破解保护密码的Excel文件;
2、依次点击菜单栏上的工具---宏----录制新宏,输入宏名字如:aa;
3、停止录制(这样得到一个空宏);
4、依次点击菜单栏上的工具---宏----宏,选aa,点编辑按钮;
5、删除窗口中的所有字符(只有几个),替换为下面的内容;
从横线下开始复制 -----------------------------
Option Explicit
Public Sub AllInternalPassords()
' Breaks orksheet and orkbook structure passords. Bob McCormick
' probably originator of base code algorithm modified for coverage
' of orkbook structure / indos passords and for multiple passords
'
' 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 passords NOT original passords
Const DBLSPACE As String = vbNeLine & vbNeLine
Const AUTHORS As String = DBLSPACE & vbNeLine & _
"Adapted from Bob McCormick base code by" & _
"Norman Harker and JE McGimpsey"
Const HEADER As String = "AllInternalPassords 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 nesgroup."
Const ALLCLEAR As String = DBLSPACE & "The orkbook should " & _
"no be free of all passord protection, so make sure you:" & _
DBLSPACE & "SAVE IT NOW!" & DBLSPACE & "and also" & _
DBLSPACE & "BACKUP!, BACKUP!!, BACKUP!!!" & _
DBLSPACE & "Also, remember that the passord as " & _
"put there for a reason. Don't stuff up crucial formulas " & _
"or data." & DBLSPACE & "Aess and use of some data " & _
"may be an offense. If in doubt, don't."
Const MSGNOPWORDS1 As String = "There ere no passords on " & _
"sheets, or orkbook structure or indos." & AUTHORS & VERSION
Const MSGNOPWORDS2 As String = "There as no protection to " & _
"orkbook structure or indos." & DBLSPACE & _
"Proceeding to unprotect sheets." & AUTHORS & VERSION
Const MSGTAKETIME As String = "After pressing OK button this " & _
"ill take some time." & DBLSPACE & "Amount of time " & _
"depends on ho many different passords, the " & _
"passords, and your puter's specification." & DBLSPACE & _
"Just be patient! Make me a coffee!" & AUTHORS & VERSION
Const MSGPWORDFOUND1 As String = "You had a Worksheet " & _
"Structure or Windos Passord set." & DBLSPACE & _
"The passord found as: " & DBLSPACE & "$$" & DBLSPACE & _
"Note it don for potential future use in other orkbooks by " & _
"the same person ho set this passord." & DBLSPACE & _
"No to check and clear other passords." & AUTHORS & VERSION
Const MSGPWORDFOUND2 As String = "You had a Worksheet " & _
"passord set." & DBLSPACE & "The passord found as: " & _
DBLSPACE & "$$" & DBLSPACE & "Note it don for potential " & _
"future use in other orkbooks by same person ho " & _
"set this passord." & DBLSPACE & "No to check and clear " & _
"other passords." & AUTHORS & VERSION
Const MSGONLYONE As String = "Only structure / indos " & _
"protected ith the passord that as just found." & _
ALLCLEAR & AUTHORS & VERSION & REPBACK
Dim 1 As Worksheet, 2 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 .ProtectWindos
End With
ShTag = False
For Each 1 In Worksheets
ShTag = ShTag Or 1.ProtectContents
Next 1
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 _
.ProtectWindos = 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, _
"$$", PWord1), vbInformation, HEADER
Exit Do 'Bypass all for...nexts
End If
End With
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
Loop Until True
On Error GoTo 0
End If
If WinTag And Not ShTag Then
MsgBox MSGONLYONE, vbInformation, HEADER
Exit Sub
End If
On Error Resume Next
For Each 1 In Worksheets
'Attempt clearance ith PWord1
1.Unprotect PWord1
Next 1
On Error GoTo 0
ShTag = False
For Each 1 In Worksheets
'Checks for all clear ShTag triggered to 1 if not.
ShTag = ShTag Or 1.ProtectContents
Next 1
If ShTag Then
For Each 1 In Worksheets
With 1
If .ProtectContents Then
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
.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 Not .ProtectContents 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(MSGPWORDFOUND2, _
"$$", PWord1), vbInformation, HEADER
'leverage finding Pord by trying on other sheets
For Each 2 In Worksheets
2.Unprotect PWord1
Next 2
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 1
End If
MsgBox ALLCLEAR & AUTHORS & VERSION & REPBACK, vbInformation, HEADER
End Sub
----------------------
复制到横线以上
6、关闭编辑窗口;
7、依次点击菜单栏上的工具---宏-----宏,选AllInternalPassords,运行,确定两次;
聚超值推荐
石头G20更干净的地面和基站