{"id":691,"date":"2011-02-10T14:19:28","date_gmt":"2011-02-10T19:19:28","guid":{"rendered":"http:\/\/it.thelibrarie.com\/weblog\/?p=691"},"modified":"2011-02-10T14:19:28","modified_gmt":"2011-02-10T19:19:28","slug":"protected-excel-spreadsheet","status":"publish","type":"post","link":"https:\/\/it.thelibrarie.com\/weblog\/2011\/02\/protected-excel-spreadsheet\/","title":{"rendered":"Protected Excel Spreadsheet"},"content":{"rendered":"<p>My boss had created an excel spreadsheet to aid us in our network configurations.  Unfortunately he&#8217;s not a very good speller.  There were quite a few spelling errors that were driving me nuts, so I was going to update the template with the correct words.  Unfortunately, again, he locked the spreadsheet to prevent changes to the code.  And he was on vacation.<\/p>\n<p>So a brief google search found this gem (<a href=\"http:\/\/jsbi.blogspot.com\/2008\/09\/how-to-easily-unprotectremove-password.html\">JSBI<\/a>), which I&#8217;ll repost here just in case it disappears.<\/p>\n<p>Open the spreadsheet with the locked cells or sheets.<br \/>\nOpen the Macros area (2007\/2010 it&#8217;s View tab, then Macros)<br \/>\nSelect Record Macro<br \/>\nJust click OK (keep the name Macro1)<br \/>\nThen click Stop Recording<br \/>\nView Macros<br \/>\nEdit Macro1<br \/>\nCopy the below in place of what is there:<\/p>\n<blockquote><p><code>Sub Macro1()<br \/>\n'<br \/>\n' Breaks worksheet and workbook structure passwords. Jason S<br \/>\n'  probably originator of base code algorithm modified for coverage<br \/>\n'  of workbook structure \/ windows passwords and for multiple passwords<br \/>\n' Jason S http:\/\/jsbi.blogspot.com<br \/>\n' Reveals hashed passwords NOT original passwords<br \/>\nConst DBLSPACE As String = vbNewLine &amp; vbNewLine<br \/>\nConst AUTHORS As String = DBLSPACE &amp; vbNewLine &amp; \"Adapted  from Bob McCormick base code by\" &amp; \"Jason S  http:\/\/jsbi.blogspot.com\"<br \/>\nConst HEADER As String = \"AllInternalPasswords User Message\"<br \/>\nConst VERSION As String = DBLSPACE &amp; \"Version 1.0 8 Sep 2008\"<br \/>\nConst REPBACK As String = DBLSPACE &amp; \"Please report failure to jasonblr@gmail.com \"<br \/>\nConst ALLCLEAR As String = DBLSPACE &amp; \"The workbook should be cleared\"<br \/>\nConst MSGNOPWORDS1 As String = \"There were no passwords on \" &amp; AUTHORS &amp; VERSION<br \/>\nConst MSGNOPWORDS2 As String = \"There was no protection to \" &amp; \"workbook structure or windows.\" &amp; DBLSPACE<br \/>\nConst MSGTAKETIME As String = \"After pressing OK button this \"  &amp; \"will take some time.\" &amp; DBLSPACE &amp; \"Amount of time \"  &amp; \"depends on how many different passwords, the \"<br \/>\nConst MSGPWORDFOUND1 As String = \"You had a Worksheet \" &amp;  \"Structure or Windows Password set.\" &amp; DBLSPACE &amp; \"The password  found was: \" &amp; DBLSPACE &amp; \"$$\" &amp; DBLSPACE &amp; \"Note it  down for potential future use in other workbooks by \" &amp; \"the same  person who set this password.\" &amp; DBLSPACE &amp; \"Now to check and  clear other passwords.\" &amp; AUTHORS &amp; VERSION<br \/>\nConst  MSGPWORDFOUND2 As String = \"You had a Worksheet \" &amp; \"password set.\"  &amp; DBLSPACE &amp; \"The password found was: \" &amp; DBLSPACE &amp;  \"$$\" &amp; DBLSPACE &amp; \"Note it down for potential \" &amp; \"future  use in other workbooks by same person who \" &amp; \"set this password.\"  &amp; DBLSPACE &amp; \"Now to check and clear \" &amp; \"other passwords.\"  &amp; AUTHORS &amp; VERSION<br \/>\nConst MSGONLYONE As String =  \"Only structure \/ windows \" &amp; \"protected with the password that was  just found.\" &amp; ALLCLEAR &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      '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; Chr(l)  &amp; Chr(m) &amp; Chr(i1) &amp; Chr(i2) &amp; Chr(i3) &amp; Chr(i4)  &amp; Chr(i5) &amp; Chr(i6) &amp; Chr(n)<br \/>\nIf .ProtectStructure = False And .ProtectWindows = False Then<br \/>\nPWord1 = Chr(i) &amp; Chr(j) &amp; Chr(k) &amp; Chr(l)  &amp; Chr(m) &amp; Chr(i1) &amp; Chr(i2) &amp; Chr(i3) &amp; Chr(i4)  &amp; Chr(i5) &amp; Chr(i6) &amp; Chr(n)<br \/>\nMsgBox Application.Substitute(MSGPWORDFOUND1, \"$$\", PWord1), vbInformation, HEADER<br \/>\nExit Do  'Bypass all for...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'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'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      '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;  Chr(l) &amp; Chr(m) &amp; Chr(i1) &amp; Chr(i2) &amp; Chr(i3) &amp;  Chr(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; Chr(m) &amp; Chr(i1) &amp; Chr(i2) &amp; Chr(i3) &amp;  Chr(i4) &amp; Chr(i5) &amp; Chr(i6) &amp; Chr(n)<br \/>\nMsgBox Application.Substitute(MSGPWORDFOUND2, \"$$\", PWord1), vbInformation, HEADER<br \/>\n'leverage finding Pword by trying on other sheets<br \/>\nFor Each w2 In Worksheets<br \/>\nw2.Unprotect PWord1<br \/>\nNext w2<br \/>\nExit Do  'Bypass all for...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 \/>\n'<br \/>\nEnd Sub<\/code><\/p><\/blockquote>\n<p>Then run Macro1.  This may take a while depending on the speed of the machine.  It looked like excel locked up on my test system.  After a minute or two the alerts pop up with the password.  In my case it was &#8220;password123&#8221;.  Secure?  Sure.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My boss had created an excel spreadsheet to aid us in our network configurations. Unfortunately he&#8217;s not a very good speller. There were quite a few spelling errors that were driving me nuts, so I was going to update the template with the correct words. Unfortunately, again, he locked the spreadsheet to prevent changes to &hellip; <a href=\"https:\/\/it.thelibrarie.com\/weblog\/2011\/02\/protected-excel-spreadsheet\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Protected Excel Spreadsheet<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-691","post","type-post","status-publish","format-standard","hentry","category-microsoft"],"_links":{"self":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/comments?post=691"}],"version-history":[{"count":1,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/691\/revisions"}],"predecessor-version":[{"id":692,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/691\/revisions\/692"}],"wp:attachment":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/media?parent=691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/categories?post=691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/tags?post=691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}