Jsbi

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Sunday, 7 September 2008

How to easily Unprotect/Remove Password from a Protected Excel Worksheet

Posted on 23:12 by Unknown
You may already know how easy it is to protect Microsoft Office Excel worksheets and workbooks from unauthorized changes with the help of a password. But, what to do if you can’t remember the password you used for protecting OR you downloaded an excel from the internet and would like to have a look at the formula's or the embeded information - but all that data might be inaccessible due to the password protection.

I have a very simple method by which you can easily recover the password and also un-protect the worksheet or workbook. Please note : this method will only remove the protection from the excel file and not the password used to open the excel file itself.

Open the excel file which is password protected and goto Macro's (I am using Office 2007 so the menu's maybe different View >> Macros). Click on "Record Macro >> OK" and then click on "Stop Recording" from the same menu. Now goto "View Macros", you will find a Macro with a default name E.g. Macro1 - Select the macro name and click on Edit. Now a Visual Basic Editor opens up. Re-place the default code and Paste the below code.


Sub Macro1()
'
' Breaks worksheet and workbook structure passwords. Jason S

' probably originator of base code algorithm modified for coverage

' of workbook structure / windows passwords and for multiple passwords

' Jason S http://jsbi.blogspot.com

' Reveals hashed passwords NOT original passwords

Const DBLSPACE As String = vbNewLine & vbNewLine

Const AUTHORS As String = DBLSPACE & vbNewLine & "Adapted from Bob McCormick base code by" & "Jason S http://jsbi.blogspot.com"

Const HEADER As String = "AllInternalPasswords User Message"

Const VERSION As String = DBLSPACE & "Version 1.0 8 Sep 2008"

Const REPBACK As String = DBLSPACE & "Please report failure to jasonblr@gmail.com "

Const ALLCLEAR As String = DBLSPACE & "The workbook should be cleared"

Const MSGNOPWORDS1 As String = "There were no passwords on " & AUTHORS & VERSION

Const MSGNOPWORDS2 As String = "There was no protection to " & "workbook structure or windows." & DBLSPACE


Const MSGTAKETIME As String = "After pressing OK button this " & "will take some time." & DBLSPACE & "Amount of time " & "depends on how many different passwords, the "



Const MSGPWORDFOUND1 As String = "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 " & "the same person who set this password." & DBLSPACE & "Now to check and clear other passwords." & AUTHORS & VERSION

Const MSGPWORDFOUND2 As String = "You had a Worksheet " & "password set." & DBLSPACE & "The password found was: " & DBLSPACE & "$$" & DBLSPACE & "Note it down for potential " & "future use in other workbooks by same person who " & "set this password." & DBLSPACE & "Now to check and clear " & "other passwords." & AUTHORS & VERSION

Const MSGONLYONE As String = "Only structure / windows " & "protected with the password that was just found." & ALLCLEAR & AUTHORS & VERSION & REPBACK

Dim w1 As Worksheet, w2 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 .ProtectWindows

End With

ShTag = False

For Each w1 In Worksheets

ShTag = ShTag Or w1.ProtectContents

Next w1

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 .ProtectWindows = 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 w1 In Worksheets

'Attempt clearance with PWord1

w1.Unprotect PWord1

Next w1

On Error GoTo 0

ShTag = False

For Each w1 In Worksheets

'Checks for all clear ShTag triggered to 1 if not.

ShTag = ShTag Or w1.ProtectContents

Next w1

If ShTag Then

For Each w1 In Worksheets

With w1

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 Pword by trying on other sheets

For Each w2 In Worksheets

w2.Unprotect PWord1

Next w2

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 w1

End If

MsgBox ALLCLEAR & AUTHORS & VERSION & REPBACK, vbInformation, HEADER
'
End Sub



Finally, run the Macro(View >> Macros >> View Macros >> Run). You will get the password of the protected workbook and worksheet in Excel. I have tested the above in Microsoft Office Excel XP / 2003 / 2007
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in internet, microsoft, Office, technology, Tips, vista, windows | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • 100+ wishes on Orkut + Facebook for your Birthday!!
    Well, first of all thanks to all those numerous mails that I received from you all yesterday - it was my birthday yesterday. Unfortunately m...
  • Comodo Firewall :: A really good one
    As internet is becoming common in our house-holds so is the virus and trojan attacks. The best way to protect yourself from the Trojan warfa...
  • Complete list of Orkut Country Specific Websites – use these when Orkut is blocked to scrap
    Orkut – the popular social networking website from the Google stable has many country specific websites. Though most of us are only aware ...
  • www.kseeb.org website is down already
    When everyone is waiting anxiously for the SSLC results we have one shocker - the website where the results are to be announced is down!! Ye...
  • The Tech Evolution : 1GB memory 20 years ago and 1GB memory now
    The Intel Museum , which is located in Santa Clara, California, USA had recently introduced several new exhibits that demonstrate the transf...
  • HP PhotoSmart Free Printer Giveaway contest - Day 3 of 7
    Well, well - Here we have the day 3 of the contest for you. There was a barrage of e-mails yesterday as to what happened to the contest ques...
  • It's been long since I wrote
    Sorry Folks, it's been quite some time since I wrote - a week to be precise. Well - here goes the lame excuse. I was busy with assemblin...
  • Can your OS make some ice-cream for you? Well, Linux can!!
    We have the OS wars raging like the Cold War down under and ready to erupt any given time. In this time, I have a question for you - Can you...
  • Get 2nd PUC results on SMS for May 2012
    The Karnataka 2nd PU results for 2012 can be checked on the internet by following :  Get 2nd PUC results on SMS for May 2012 But did you kno...
  • Now watch videos on YouTube in 720p High Definition (HD) quality for Free
    YouTube recently launched an exclusive High Definition section for the US users. Users who have access to this section can watch the videos...

Categories

  • Android
  • announcements
  • Anti-Virus
  • Asus
  • Bangalore
  • blogging
  • Contests
  • FaceBook
  • Gadgets
  • google
  • Guest Article
  • health
  • HP
  • India
  • internet
  • iPhone
  • K810i
  • linux
  • mac
  • microsoft
  • Mobile
  • MotherBoards
  • mp3
  • NetBook
  • news
  • Office
  • personal
  • photoshop
  • Portable Apps
  • Printers
  • programming
  • Quotes
  • Review
  • software
  • story
  • technology
  • Tips
  • Travel
  • videos
  • vista
  • windows
  • Windows 7
  • Windows 8
  • zune

Blog Archive

  • ►  2012 (8)
    • ►  October (2)
    • ►  May (6)
  • ►  2011 (1)
    • ►  December (1)
  • ►  2010 (22)
    • ►  July (1)
    • ►  May (16)
    • ►  April (1)
    • ►  March (2)
    • ►  February (1)
    • ►  January (1)
  • ►  2009 (167)
    • ►  December (3)
    • ►  November (19)
    • ►  October (12)
    • ►  September (8)
    • ►  August (11)
    • ►  July (22)
    • ►  June (30)
    • ►  May (26)
    • ►  April (20)
    • ►  March (12)
    • ►  February (4)
  • ▼  2008 (102)
    • ►  December (3)
    • ►  November (1)
    • ►  October (10)
    • ▼  September (17)
      • How to easily Remove the Virus / Spyware - Anti-vi...
      • Who really Owns Kashmir ? An introspection
      • How to keep your computer Clean and Fast easily?
      • 100+ wishes on Orkut + Facebook for your Birthday!!
      • Apple updates iTunes 8 to fix Vista's blue screen ...
      • Google in the last 10 years - An Insight
      • Happy Onam
      • How to easily reset Administrator password in Wind...
      • What programs slow your Windows PC?
      • Apple unveils new iPod Nano and iPod Touch
      • Scientists will re-enact the Big Bang theory today!
      • Link to Offline Installer for a clean Google Chrome
      • IE8 Beta 2 : First Aid Kit :: Funny
      • How to easily Unprotect/Remove Password from a Pro...
      • Easy Fix for : Windows Picture and Fax Viewer does...
      • How to fix Windows Explorer crash when viewing fol...
      • 31 Reasons Why you Shouldn't Buy an iPhone 3G!
    • ►  August (16)
    • ►  July (5)
    • ►  June (7)
    • ►  May (10)
    • ►  April (18)
    • ►  March (15)
Powered by Blogger.

About Me

Unknown
View my complete profile