{"id":713,"date":"2015-12-04T17:17:04","date_gmt":"2015-12-04T09:17:04","guid":{"rendered":"http:\/\/www.luwl.net\/?p=713"},"modified":"2016-06-15T17:14:18","modified_gmt":"2016-06-15T09:14:18","slug":"%e7%a0%b4%e8%a7%a3excle%e7%9a%84%e5%8d%95%e5%85%83%e6%a0%bc%e4%bf%9d%e6%8a%a4","status":"publish","type":"post","link":"http:\/\/www.luwl.net\/?p=713","title":{"rendered":"\u7834\u89e3excle\u7684\u5355\u5143\u683c\u4fdd\u62a4"},"content":{"rendered":"<p>\u6dfb\u52a0\u4e00\u4e2a\u5b8f\uff0c\u7f16\u8f91\u4ee3\u7801\uff1a<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n\r\nPublic Sub AllInternalPasswords()\r\n' Breaks worksheet and workbook structure passwords. Bob McCormick\r\n' probably originator of base code algorithm modified for coverage\r\n' of workbook structure \/ windows passwords and for multiple passwords\r\n'\r\n' Norman Harker and JE McGimpsey 27-Dec-2002 (Version 1.1)\r\n' Modified 2003-Apr-04 by JEM: All msgs to constants, and\r\n' eliminate one Exit Sub (Version 1.1.1)\r\n' Reveals hashed passwords NOT original passwords\r\nConst DBLSPACE As String = vbNewLine &amp; vbNewLine\r\nConst AUTHORS As String = DBLSPACE &amp; vbNewLine &amp; _\r\n&quot;Adapted from Bob McCormick base code by&quot; &amp; _\r\n&quot;Norman Harker and JE McGimpsey&quot;\r\nConst HEADER As String = &quot;AllInternalPasswords User Message&quot;\r\nConst VERSION As String = DBLSPACE &amp; &quot;Version 1.1.1 2003-Apr-04&quot;\r\nConst REPBACK As String = DBLSPACE &amp; &quot;Please report failure &quot; &amp; _\r\n&quot;to the microsoft.public.excel.programming newsgroup.&quot;\r\nConst ALLCLEAR As String = DBLSPACE &amp; &quot;The workbook should &quot; &amp; _\r\n&quot;now be free of all password protection, so make sure you:&quot; &amp; _\r\nDBLSPACE &amp; &quot;SAVE IT NOW!&quot; &amp; DBLSPACE &amp; &quot;and also&quot; &amp; _\r\nDBLSPACE &amp; &quot;BACKUP!, BACKUP!!, BACKUP!!!&quot; &amp; _\r\nDBLSPACE &amp; &quot;Also, remember that the password was &quot; &amp; _\r\n&quot;put there for a reason. Don't stuff up crucial formulas &quot; &amp; _\r\n&quot;or data.&quot; &amp; DBLSPACE &amp; &quot;Access and use of some data &quot; &amp; _\r\n&quot;may be an offense. If in doubt, don't.&quot;\r\nConst MSGNOPWORDS1 As String = &quot;There were no passwords on &quot; &amp; _\r\n&quot;sheets, or workbook structure or windows.&quot; &amp; AUTHORS &amp; VERSION\r\nConst MSGNOPWORDS2 As String = &quot;There was no protection to &quot; &amp; _\r\n&quot;workbook structure or windows.&quot; &amp; DBLSPACE &amp; _\r\n&quot;Proceeding to unprotect sheets.&quot; &amp; AUTHORS &amp; VERSION\r\nConst MSGTAKETIME As String = &quot;After pressing OK button this &quot; &amp; _\r\n&quot;will take some time.&quot; &amp; DBLSPACE &amp; &quot;Amount of time &quot; &amp; _\r\n&quot;depends on how many different passwords, the &quot; &amp; _\r\n&quot;passwords, and your computer's specification.&quot; &amp; DBLSPACE &amp; _\r\n&quot;Just be patient! Make me a coffee!&quot; &amp; AUTHORS &amp; VERSION\r\nConst MSGPWORDFOUND1 As String = &quot;You had a Worksheet &quot; &amp; _\r\n&quot;Structure or Windows Password set.&quot; &amp; DBLSPACE &amp; _\r\n&quot;The password found was: &quot; &amp; DBLSPACE &amp; &quot;$$&quot; &amp; DBLSPACE &amp; _\r\n&quot;Note it down for potential future use in other workbooks by &quot; &amp; _\r\n&quot;the same person who set this password.&quot; &amp; DBLSPACE &amp; _\r\n&quot;Now to check and clear other passwords.&quot; &amp; AUTHORS &amp; VERSION\r\nConst MSGPWORDFOUND2 As String = &quot;You had a Worksheet &quot; &amp; _\r\n&quot;password set.&quot; &amp; DBLSPACE &amp; &quot;The password found was: &quot; &amp; _\r\nDBLSPACE &amp; &quot;$$&quot; &amp; DBLSPACE &amp; &quot;Note it down for potential &quot; &amp; _\r\n&quot;future use in other workbooks by same person who &quot; &amp; _\r\n&quot;set this password.&quot; &amp; DBLSPACE &amp; &quot;Now to check and clear &quot; &amp; _\r\n&quot;other passwords.&quot; &amp; AUTHORS &amp; VERSION\r\nConst MSGONLYONE As String = &quot;Only structure \/ windows &quot; &amp; _\r\n&quot;protected with the password that was just found.&quot; &amp; _\r\nALLCLEAR &amp; AUTHORS &amp; VERSION &amp; REPBACK\r\nDim w1 As Worksheet, w2 As Worksheet\r\nDim i As Integer, j As Integer, k As Integer, l As Integer\r\nDim m As Integer, n As Integer, i1 As Integer, i2 As Integer\r\nDim i3 As Integer, i4 As Integer, i5 As Integer, i6 As Integer\r\nDim PWord1 As String\r\nDim ShTag As Boolean, WinTag As Boolean\r\nApplication.ScreenUpdating = False\r\nWith ActiveWorkbook\r\nWinTag = .ProtectStructure Or .ProtectWindows\r\nEnd With\r\nShTag = False\r\nFor Each w1 In Worksheets\r\nShTag = ShTag Or w1.ProtectContents\r\nNext w1\r\nIf Not ShTag And Not WinTag Then\r\nMsgBox MSGNOPWORDS1, vbInformation, HEADER\r\nExit Sub\r\nEnd If\r\nMsgBox MSGTAKETIME, vbInformation, HEADER\r\nIf Not WinTag Then\r\nMsgBox MSGNOPWORDS2, vbInformation, HEADER\r\nElse\r\nOn Error Resume Next\r\nDo 'dummy do loop\r\nFor i = 65 To 66: For j = 65 To 66: For k = 65 To 66\r\nFor l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66\r\nFor i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66\r\nFor i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126\r\nWith ActiveWorkbook\r\n.Unprotect Chr(i) &amp; Chr(j) &amp; Chr(k) &amp; _\r\nChr(l) &amp; Chr(m) &amp; Chr(i1) &amp; Chr(i2) &amp; _\r\nChr(i3) &amp; Chr(i4) &amp; Chr(i5) &amp; Chr(i6) &amp; Chr(n)\r\nIf .ProtectStructure = False And _\r\n.ProtectWindows = False Then\r\nPWord1 = Chr(i) &amp; Chr(j) &amp; Chr(k) &amp; Chr(l) &amp; _\r\nChr(m) &amp; Chr(i1) &amp; Chr(i2) &amp; Chr(i3) &amp; _\r\nChr(i4) &amp; Chr(i5) &amp; Chr(i6) &amp; Chr(n)\r\nMsgBox Application.Substitute(MSGPWORDFOUND1, _\r\n&quot;$$&quot;, PWord1), vbInformation, HEADER\r\nExit Do 'Bypass all for...nexts\r\nEnd If\r\nEnd With\r\nNext: Next: Next: Next: Next: Next\r\nNext: Next: Next: Next: Next: Next\r\nLoop Until True\r\nOn Error GoTo 0\r\nEnd If\r\nIf WinTag And Not ShTag Then\r\nMsgBox MSGONLYONE, vbInformation, HEADER\r\nExit Sub\r\nEnd If\r\nOn Error Resume Next\r\nFor Each w1 In Worksheets\r\n'Attempt clearance with PWord1\r\nw1.Unprotect PWord1\r\nNext w1\r\nOn Error GoTo 0\r\nShTag = False\r\nFor Each w1 In Worksheets\r\n'Checks for all clear ShTag triggered to 1 if not.\r\nShTag = ShTag Or w1.ProtectContents\r\nNext w1\r\nIf ShTag Then\r\nFor Each w1 In Worksheets\r\nWith w1\r\nIf .ProtectContents Then\r\nOn Error Resume Next\r\nDo 'Dummy do loop\r\nFor i = 65 To 66: For j = 65 To 66: For k = 65 To 66\r\nFor l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66\r\nFor i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66\r\nFor i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126\r\n.Unprotect Chr(i) &amp; Chr(j) &amp; Chr(k) &amp; _\r\nChr(l) &amp; Chr(m) &amp; Chr(i1) &amp; Chr(i2) &amp; Chr(i3) &amp; _\r\nChr(i4) &amp; Chr(i5) &amp; Chr(i6) &amp; Chr(n)\r\nIf Not .ProtectContents Then\r\nPWord1 = Chr(i) &amp; Chr(j) &amp; Chr(k) &amp; Chr(l) &amp; _\r\nChr(m) &amp; Chr(i1) &amp; Chr(i2) &amp; Chr(i3) &amp; _\r\nChr(i4) &amp; Chr(i5) &amp; Chr(i6) &amp; Chr(n)\r\nMsgBox Application.Substitute(MSGPWORDFOUND2, _\r\n&quot;$$&quot;, PWord1), vbInformation, HEADER\r\n'leverage finding Pword by trying on other sheets\r\nFor Each w2 In Worksheets\r\nw2.Unprotect PWord1\r\nNext w2\r\nExit Do 'Bypass all for...nexts\r\nEnd If\r\nNext: Next: Next: Next: Next: Next\r\nNext: Next: Next: Next: Next: Next\r\nLoop Until True\r\nOn Error GoTo 0\r\nEnd If\r\nEnd With\r\nNext w1\r\nEnd If\r\nMsgBox ALLCLEAR &amp; AUTHORS &amp; VERSION &amp; REPBACK, vbInformation, HEADER\r\nEnd Sub\r\n\r\n<\/pre>\n<p>\u4e24\u6b21\u786e\u5b9a\uff0c\u6700\u540e\u51fa\u73b0\u7684\u5bc6\u7801\u5e76\u4e0d\u662f\u539f\u59cb\u5bc6\u7801\uff0c\u53ea\u662f\u8fd9\u4e2a\u5bc6\u7801\u548c\u539f\u6765\u7684\u5bc6\u7801\u4e00\u6837\u53ef\u4ee5\u5171\u540c\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6dfb\u52a0\u4e00\u4e2a\u5b8f\uff0c\u7f16\u8f91\u4ee3\u7801\uff1a Public Sub AllInternalPasswo &hellip; <a href=\"http:\/\/www.luwl.net\/?p=713\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-713","post","type-post","status-publish","format-standard","hentry","category-zj"],"_links":{"self":[{"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/posts\/713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.luwl.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=713"}],"version-history":[{"count":3,"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/posts\/713\/revisions"}],"predecessor-version":[{"id":773,"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/posts\/713\/revisions\/773"}],"wp:attachment":[{"href":"http:\/\/www.luwl.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.luwl.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=713"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.luwl.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}