{"id":386,"date":"2015-08-11T13:13:53","date_gmt":"2015-08-11T05:13:53","guid":{"rendered":"http:\/\/www.huike007.cn\/?p=386"},"modified":"2015-08-11T13:13:53","modified_gmt":"2015-08-11T05:13:53","slug":"%e5%8e%bb%e9%99%a4excel%e5%b7%a5%e4%bd%9c%e8%a1%a8%e4%bf%9d%e6%8a%a4%e5%af%86%e7%a0%81","status":"publish","type":"post","link":"http:\/\/www.huike007.cn\/?p=386","title":{"rendered":"\u53bb\u9664Excel\u5de5\u4f5c\u8868\u4fdd\u62a4\u5bc6\u7801"},"content":{"rendered":"<p>\u53bb\u9664Excel\u5de5\u4f5c\u8868\u4fdd\u62a4\u5bc6\u7801<br \/>\n\u64cd\u4f5c\u6b65\u9aa4\uff1a<br \/>\n1. \u6253\u5f00\u9700\u8981\u7834\u89e3\u5bc6\u7801\u7684Excel\uff1b<br \/>\n2. Alt+F11\uff0c\u8fdb\u5165VBA\u7f16\u8f91\u754c\u9762\uff1b<br \/>\n3. \u63d2\u5165 &#8212; \u6a21\u5757(Module)\uff1b<br \/>\n4. \u5728\u53f3\u8fb9Module\u7684\u7a7a\u767d\u7f16\u8f91\u533a\u57df\uff0c\u590d\u5236\u7c98\u8d34\u4e0b\u9762\u6240\u6709\u5185\u5bb9\uff1b<br \/>\n5. F5\uff0c\u8fd0\u884c\u8be5VBA\u547d\u4ee4\uff1b<br \/>\nOption Explicit<br \/>\nPublic Sub AllInternalPasswords()<br \/>\n&#8216; Breaks worksheet and workbook structure passwords. Bob McCormick<br \/>\n&#8216; probably originator of base code algorithm modified for coverage<br \/>\n&#8216; of workbook structure \/ windows passwords and for multiple passwords<br \/>\n&#8216;<br \/>\n&#8216; Norman Harker and JE McGimpsey 27-Dec-2002 (Version 1.1)<br \/>\n&#8216; Modified 2003-Apr-04 by JEM: All msgs to constants, and<br \/>\n&#8216; eliminate one Exit Sub (Version 1.1.1)<br \/>\n&#8216; Reveals hashed passwords NOT original passwords<br \/>\nConst DBLSPACE As String = vbNewLine &amp; vbNewLine<br \/>\nConst AUTHORS As String = DBLSPACE &amp; vbNewLine &amp; _<br \/>\n&#8220;Adapted from Bob McCormick base code by&#8221; &amp; _<br \/>\n&#8220;Norman Harker and JE McGimpsey&#8221;<br \/>\nConst HEADER As String = &#8220;AllInternalPasswords User Message&#8221;<br \/>\nConst VERSION As String = DBLSPACE &amp; &#8220;Version 1.1.1 2003-Apr-04&#8221;<br \/>\nConst REPBACK As String = DBLSPACE &amp; &#8220;Please report failure &#8221; &amp; _<br \/>\n&#8220;to the microsoft.public.excel.programming newsgroup.&#8221;<br \/>\nConst ALLCLEAR As String = DBLSPACE &amp; &#8220;The workbook should &#8221; &amp; _<br \/>\n&#8220;now be free of all password protection, so make sure you:&#8221; &amp; _<br \/>\nDBLSPACE &amp; &#8220;SAVE IT NOW!&#8221; &amp; DBLSPACE &amp; &#8220;and also&#8221; &amp; _<br \/>\nDBLSPACE &amp; &#8220;BACKUP!, BACKUP!!, BACKUP!!!&#8221; &amp; _<br \/>\nDBLSPACE &amp; &#8220;Also, remember that the password was &#8221; &amp; _<br \/>\n&#8220;put there for a reason. Don&#8217;t stuff up crucial formulas &#8221; &amp; _<br \/>\n&#8220;or data.&#8221; &amp; DBLSPACE &amp; &#8220;Access and use of some data &#8221; &amp; _<br \/>\n&#8220;may be an offense. If in doubt, don&#8217;t.&#8221;<br \/>\nConst MSGNOPWORDS1 As String = &#8220;There were no passwords on &#8221; &amp; _<br \/>\n&#8220;sheets, or workbook structure or windows.&#8221; &amp; AUTHORS &amp; VERSION<br \/>\nConst MSGNOPWORDS2 As String = &#8220;There was no protection to &#8221; &amp; _<br \/>\n&#8220;workbook structure or windows.&#8221; &amp; DBLSPACE &amp; _<br \/>\n&#8220;Proceeding to unprotect sheets.&#8221; &amp; AUTHORS &amp; VERSION<br \/>\nConst MSGTAKETIME As String = &#8220;After pressing OK button this &#8221; &amp; _<br \/>\n&#8220;will take some time.&#8221; &amp; DBLSPACE &amp; &#8220;Amount of time &#8221; &amp; _<br \/>\n&#8220;depends on how many different passwords, the &#8221; &amp; _<br \/>\n&#8220;passwords, and your computer&#8217;s specification.&#8221; &amp; DBLSPACE &amp; _<br \/>\n&#8220;Just be patient! Make me a coffee!&#8221; &amp; AUTHORS &amp; VERSION<br \/>\nConst MSGPWORDFOUND1 As String = &#8220;You had a Worksheet &#8221; &amp; _<br \/>\n&#8220;Structure or Windows Password set.&#8221; &amp; DBLSPACE &amp; _<br \/>\n&#8220;The password found was: &#8221; &amp; DBLSPACE &amp; &#8220;$$&#8221; &amp; DBLSPACE &amp; _<br \/>\n&#8220;Note it down for potential future use in other workbooks by &#8221; &amp; _<br \/>\n&#8220;the same person who set this password.&#8221; &amp; DBLSPACE &amp; _<br \/>\n&#8220;Now to check and clear other passwords.&#8221; &amp; AUTHORS &amp; VERSION<br \/>\nConst MSGPWORDFOUND2 As String = &#8220;You had a Worksheet &#8221; &amp; _<br \/>\n&#8220;password set.&#8221; &amp; DBLSPACE &amp; &#8220;The password found was: &#8221; &amp; _<br \/>\nDBLSPACE &amp; &#8220;$$&#8221; &amp; DBLSPACE &amp; &#8220;Note it down for potential &#8221; &amp; _<br \/>\n&#8220;future use in other workbooks by same person who &#8221; &amp; _<br \/>\n&#8220;set this password.&#8221; &amp; DBLSPACE &amp; &#8220;Now to check and clear &#8221; &amp; _<br \/>\n&#8220;other passwords.&#8221; &amp; AUTHORS &amp; VERSION<br \/>\nConst MSGONLYONE As String = &#8220;Only structure \/ windows &#8221; &amp; _<br \/>\n&#8220;protected with the password that was just found.&#8221; &amp; _<br \/>\nALLCLEAR &amp; AUTHORS &amp; VERSION &amp; REPBACK<br \/>\nDim w1 As Worksheet, w2 As Worksheet<br \/>\nDim i As Integer, j As Integer, k As Integer, l As Integer<br \/>\nDim m As Integer, n As Integer, i1 As Integer, i2 As Integer<br \/>\nDim i3 As Integer, i4 As Integer, i5 As Integer, i6 As Integer<br \/>\nDim PWord1 As String<br \/>\nDim ShTag As Boolean, WinTag As Boolean<br \/>\nApplication.ScreenUpdating = False<br \/>\nWith ActiveWorkbook<br \/>\nWinTag = .ProtectStructure or .ProtectWindows<br \/>\nEnd With<br \/>\nShTag = False<br \/>\nFor Each w1 In Worksheets<br \/>\nShTag = ShTag or w1.ProtectContents<br \/>\nNext w1<br \/>\nIf Not ShTag And Not WinTag Then<br \/>\nMsgBox MSGNOPWORDS1, vbInformation, HEADER<br \/>\nExit Sub<br \/>\nEnd If<br \/>\nMsgBox MSGTAKETIME, vbInformation, HEADER<br \/>\nIf Not WinTag Then<br \/>\nMsgBox MSGNOPWORDS2, vbInformation, HEADER<br \/>\nElse<br \/>\nOn Error Resume Next<br \/>\nDo &#8216;dummy do loop<br \/>\nFor i = 65 To 66: For j = 65 To 66: For k = 65 To 66<br \/>\nFor l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66<br \/>\nFor i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66<br \/>\nFor i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126<br \/>\nWith ActiveWorkbook<br \/>\n.Unprotect Chr(i) &amp; Chr(j) &amp; Chr(k) &amp; _<br \/>\nChr(l) &amp; Chr(m) &amp; Chr(i1) &amp; Chr(i2) &amp; _<br \/>\nChr(i3) &amp; Chr(i4) &amp; Chr(i5) &amp; Chr(i6) &amp; Chr(n)<br \/>\nIf .ProtectStructure = False And _<br \/>\n.ProtectWindows = False Then<br \/>\nPWord1 = Chr(i) &amp; Chr(j) &amp; Chr(k) &amp; Chr(l) &amp; _<br \/>\nChr(m) &amp; Chr(i1) &amp; Chr(i2) &amp; Chr(i3) &amp; _<br \/>\nChr(i4) &amp; Chr(i5) &amp; Chr(i6) &amp; Chr(n)<br \/>\nMsgBox Application.Substitute(MSGPWORDFOUND1, _<br \/>\n&#8220;$$&#8221;, PWord1), vbInformation, HEADER<br \/>\nExit Do &#8216;Bypass all for&#8230;nexts<br \/>\nEnd If<br \/>\nEnd With<br \/>\nNext: Next: Next: Next: Next: Next<br \/>\nNext: Next: Next: Next: Next: Next<br \/>\nLoop Until True<br \/>\nOn Error GoTo 0<br \/>\nEnd If<br \/>\nIf WinTag And Not ShTag Then<br \/>\nMsgBox MSGONLYONE, vbInformation, HEADER<br \/>\nExit Sub<br \/>\nEnd If<br \/>\nOn Error Resume Next<br \/>\nFor Each w1 In Worksheets<br \/>\n&#8216;Attempt clearance with PWord1<br \/>\nw1.Unprotect PWord1<br \/>\nNext w1<br \/>\nOn Error GoTo 0<br \/>\nShTag = False<br \/>\nFor Each w1 In Worksheets<br \/>\n&#8216;Checks for all clear ShTag triggered to 1 if not.<br \/>\nShTag = ShTag or w1.ProtectContents<br \/>\nNext w1<br \/>\nIf ShTag Then<br \/>\nFor Each w1 In Worksheets<br \/>\nWith w1<br \/>\nIf .ProtectContents Then<br \/>\nOn Error Resume Next<br \/>\nDo &#8216;Dummy do loop<br \/>\nFor i = 65 To 66: For j = 65 To 66: For k = 65 To 66<br \/>\nFor l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66<br \/>\nFor i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66<br \/>\nFor i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126<br \/>\n.Unprotect Chr(i) &amp; Chr(j) &amp; Chr(k) &amp; _<br \/>\nChr(l) &amp; Chr(m) &amp; Chr(i1) &amp; Chr(i2) &amp; Chr(i3) &amp; _<br \/>\nChr(i4) &amp; Chr(i5) &amp; Chr(i6) &amp; Chr(n)<br \/>\nIf Not .ProtectContents Then<br \/>\nPWord1 = Chr(i) &amp; Chr(j) &amp; Chr(k) &amp; Chr(l) &amp; _<br \/>\nChr(m) &amp; Chr(i1) &amp; Chr(i2) &amp; Chr(i3) &amp; _<br \/>\nChr(i4) &amp; Chr(i5) &amp; Chr(i6) &amp; Chr(n)<br \/>\nMsgBox Application.Substitute(MSGPWORDFOUND2, _<br \/>\n&#8220;$$&#8221;, PWord1), vbInformation, HEADER<br \/>\n&#8216;leverage finding Pword by trying on other sheets<br \/>\nFor Each w2 In Worksheets<br \/>\nw2.Unprotect PWord1<br \/>\nNext w2<br \/>\nExit Do &#8216;Bypass all for&#8230;nexts<br \/>\nEnd If<br \/>\nNext: Next: Next: Next: Next: Next<br \/>\nNext: Next: Next: Next: Next: Next<br \/>\nLoop Until True<br \/>\nOn Error GoTo 0<br \/>\nEnd If<br \/>\nEnd With<br \/>\nNext w1<br \/>\nEnd If<br \/>\nMsgBox ALLCLEAR &amp; AUTHORS &amp; VERSION &amp; REPBACK, vbInformation, HEADER<br \/>\nEnd Sub<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53bb\u9664Excel\u5de5\u4f5c\u8868\u4fdd\u62a4\u5bc6\u7801 \u64cd\u4f5c\u6b65\u9aa4\uff1a 1. \u6253\u5f00\u9700\u8981\u7834\u89e3\u5bc6\u7801\u7684Excel\uff1b 2. Alt+F11\uff0c\u8fdb\u5165VB [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[181],"tags":[346],"_links":{"self":[{"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/posts\/386"}],"collection":[{"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=386"}],"version-history":[{"count":1,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/posts\/386\/revisions"}],"predecessor-version":[{"id":387,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/posts\/386\/revisions\/387"}],"wp:attachment":[{"href":"http:\/\/www.huike007.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=386"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}