1、网上下载了工作簿,发现居然有密码!xxoo,既然放网上干嘛要加密码啊?!后来网上找到使用VBA破解工作表密码的方法,拿来分享。首先,尝试打开,工作簿时,提示有密码:使用快捷键Ctrl+F11键,打开VBA编辑界面,点击“插入”菜单下的子菜单“模块”:在模块编辑器中输入以下代,码:Option ExplicitPublic Sub AllInternalPasswords()Const DBLSPACE As St,ring=vbnewline & vbnewlineConst AUTHORS As String=DBLSPACE & vbnewline,& _Adapted from Bob
2、McCormick base code by & _Norman Harker and JE,MCGImpseyConst HEADER As String=AllInternalPasswords User MessageC,onst VERSION As String=DBLSPACEConst REPBACK As String=DBLSPACE & Ple,ase report failure & _to the microsoft.public.Excel.programming ne,wsgroup.Const ALLCLEAR As String=DBLSPACE & The w
3、orkbook should &,_now be free of all password protection, so make sure you: & _DBLSP,ACE & SAVE IT NOW! & DBLSPACE & and also & _DBLSPACE & BACKUP!, B,ACKUP!, BACKUP! & _DBLSPACE & Also, remember that the password wa,s & _put there for a reason. Dont stuff up crucial formulas & _,or data. & DBLSPACE
4、 & Access and use of some data & _may be an of,fense. If in doubt, dont.Const MSGNOPWORDS1 As String=There were no,passwords on & _sheets, or workbook structure or windows. & AUTHO,RS & VERSIONConst MSGNOPWORDS2 As String=There was no protection to ,& _workbook structure or windows. & DBLSPACE & _Pr
5、oceeding to unpr,otect sheets. & AUTHORS & VERSIONConst MSGTAKETIME As String=After p,ressing OK button this & _will take some time. & DBLSPACE & Amoun,t of time & _depends on how many different passwords, the & _pas,swords, and your computers specification. & DBLSPACE & _Just be pat,ient! Make me a
6、 coffee! & AUTHORS & VERSIONConst MSGPWORDFOUND1 As St,ring=You had a Worksheet & _Structure or Windows Password set. &,DBLSPACE & _The password found was: & DBLSPACE & $ & DBLSPACE &,_Note it down for potential future use in other workbooks by & _t,he same person who set this password. & DBLSPACE &
7、 _Now to check and,clear other passwords. & AUTHORS & VERSIONConst MSGPWORDFOUND2 As St,ring=You had a Worksheet & _password set. & DBLSPACE & The passw,ord found was: & _DBLSPACE & $ & DBLSPACE & Note it down for pot,ential & _future use in other workbooks by same person who & _s,et this password.
8、& DBLSPACE & Now to check and clear & _other p,asswords. & AUTHORS & VERSIONConst MSGonLYONE As String=only structu,re / windows & _protected with the password that was just found. &,_ALLCLEAR & AUTHORS & VERSION & REPBACKDim w1 As Worksheet, w2 As Wor,ksheetDim i As Integer, j As Integer, k As Inte
9、ger, l As IntegerDim m,As Integer, n As Integer, i1 As Integer, i2 As IntegerDim i3 As Intege,r, i4 As Integer, i5 As Integer, i6 As IntegerDim PWord1 As StringDim,ShTag As Boolean, WinTag As BooleanApplication.ScreenUpdating=FalseWit,h ActiveWorkbookWinTag=.ProtectStructure Or .ProtectWindowsEnd Wi
10、thShT,ag=FalseFor Each w1 In WorksheetsShTag=ShTag Or w1.ProtectContentsNext,w1If Not ShTag And Not WinTag ThenMsgBox MSGNOPWORDS1, vbInformation,HEADERExit SubEnd IfMsgBox MSGTAKETIME, vbInformation, HEADERIf Not W,inTag ThenMsgBox MSGNOPWORDS2, vbInformation, HEADERElseOn Error Resum,e NextDo dumm
11、y do loopFor i=65 To 66: For j=65 To 66: For k=65 To 66F,or l=65 To 66: For m=65 To 66: For i1=65 To 66For i2=65 To 66: For i3=,65 To 66: For i4=65 To 66For i5=65 To 66: For i6=65 To 66: For n=32 To,126With ActiveWorkbook.Unprotect Chr(i) & Chr(j) & Chr(k) & _Chr(l) &,Chr(m) & Chr(i1) & Chr(i2) & _C
12、hr(i3) & Chr(i4) & Chr(i5) & Chr(i6) &,Chr(n)If .ProtectStructure=False And _.ProtectWindows=False ThenPWord,1=Chr(i) & Chr(j) & Chr(k) & Chr(l) & _Chr(m) & Chr(i1) & Chr(i2) & Ch,r(i3) & _Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)MsgBox Application.Substi,tute(MSGPWORDFOUND1, _$, PWord1), vbInformation,
13、HEADERExit Do Byp,ass all for.nextsEnd IfEnd WithNext: Next: Next: Next: Next: NextNex,t: Next: Next: Next: Next: NextLoop Until TrueOn Error GoTo 0End IfIf,WinTag And Not ShTag ThenMsgBox MSGONLYONE, vbInformation, HEADERExit,SubEnd IfOn Error Resume NextFor Each w1 In WorksheetsAttempt clearan,ce
14、with PWord1w1.Unprotect PWord1Next w1On Error GoTo 0ShTag=FalseFor,Each w1 In WorksheetsChecks for all clear ShTag triggered to 1 if not,.ShTag=ShTag Or w1.ProtectContentsNext w1If ShTag ThenFor Each w1 In W,orksheetsWith w1If .ProtectContents ThenOn Error Resume NextDo Dummy,do loopFor i=65 To 66:
15、For j=65 To 66: For k=65 To 66For l=65 To 66: F,or m=65 To 66: For i1=65 To 66For i2=65 To 66: For i3=65 To 66: For i4,=65 To 66For i5=65 To 66: For i6=65 To 66: For n=32 To 126.Unprotect C,hr(i) & Chr(j) & Chr(k) & _Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i,3) & _Chr(i4) & Chr(i5) & Chr(i6) & Chr
16、(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.S,ubstitute(MSGPWORDFOUND2, _$, PWord1), vbInformation, HEADERlevera,ge finding Pword by trying on other sheetsFor Each w2 In Wor
17、ksheetsw2.,Unprotect PWord1Next w2Exit Do Bypass all for.nextsEnd IfNext: Next,: Next: Next: Next: NextNext: Next: Next: Next: Next: NextLoop Until T,rueOn Error GoTo 0End IfEnd WithNext w1End IfMsgBox ALLCLEAR & AUTHORS,& VERSION & REPBACK, vbInformation, HEADEREnd Sub点击运行:破解过程需要几分钟,有几,次对话框弹出,都是英文的,留意对话框中如下内容:标注部分即为密码。虽然不是原始密码,但是用这个密码照样可以打开工作簿的。,在线ERP http:/