Actuarial Outpost
 
Go Back   Actuarial Outpost > Actuarial Discussion Forum > Software & Technology
FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions

Meet the Employees of DW Simpson
Patty Jacobsen Simpson, Bob Morand, Kristyn Sakelaris, Sean Loboda, KC Cho, Maureen Matous, Ellen Page
Aaron Benton, Becki Tobia, Kimberly Skora, Margit Vogele, Barclay Burns, Jason Blundy, Dan Karrow, Tom Troceen
Valorie Mulder, Marianne Westphal, Carol Lee, Jennifer Retford, Kieran Welsh-Phillips, Lindsey Nelson, Emily Paxton
Angie Wachholz, Derek Mulder, Julie Garwood, Caitlin Cunningham, David Benton, Dave Retford, Sarah Cleveland, Rhonda Glick
Genevieve Shannon, Meghan Bautista, Carol Datu, Barb Rave, Jesus Perez, Dan Kane, Chris Zdenek, Scott Simon, Kriss Wells


Reply
 
Thread Tools Display Modes
  #1  
Old 07-22-2010, 03:42 PM
HangerAngler's Avatar
HangerAngler HangerAngler is offline
Member
 
Join Date: Oct 2003
Location: downwind
Posts: 10,967
Default Excel macro to unlock a password protected tab (known password)

Does anybody know how an Excel VBA macro can be written so it unlocks a tab that is password protected? The password is known.
__________________
Knock my block off.
Reply With Quote
  #2  
Old 07-22-2010, 03:48 PM
Abused Student's Avatar
Abused Student Abused Student is online now
Member
SOA
 
Join Date: Feb 2007
Location: The Eighth Circle of Hell
Favorite beer: Cold and lots of it
Posts: 35,871
Default

Sub UnprotectCurrent()
ActiveWorkbook.ActiveSheet.Unprotect ("password")


End Sub
__________________
GAME ON!!!!!!! Let your ness show. Join the D&D fun. Started but applications still accepted


Officially assigned the role of Dictator, 9/30/09. Bow to my whims.
Reply With Quote
  #3  
Old 07-22-2010, 05:35 PM
dumples dumples is offline
Member
 
Join Date: Sep 2003
Posts: 1,070
Default

What AS said, though if you know the name of the worksheet you should use it directly.

Thisworkbook.worksheets("Sheet1").Unprotect ("password")

One question that I would ask is why do you want to unlock it? If you want to unlock it so that you can perform some operations on it with code and then re-lock it, then you can save yourself a hastle by just locking it with VB and setting the userInterfaceOnly command to true.

This code will run without an error:
Code:
Sub tle()
Dim ws As Worksheet
Set ws = ActiveSheet
ws.Protect userInterfaceOnly:=True
ws.Cells(1, 1) = ws.Cells(1, 2)
End Sub
While this code will bomb
Code:
 
Sub par()
Dim ws As Worksheet
Set ws = ActiveSheet
ws.Protect userInterfaceOnly:=False
ws.Cells(1, 1) = ws.Cells(1, 2)
End Sub
Reply With Quote
  #4  
Old 07-23-2010, 07:32 AM
campbell's Avatar
campbell campbell is offline
Mary Pat Campbell
SOA AAA
 
Join Date: Nov 2003
Location: NY
Studying for Japanese
Favorite beer: Murphy's Irish Stout
Posts: 36,298
Blog Entries: 5
Default

One question that I would ask is why would you want it password-locked at all? [I find password-locking to be obnoxious; and much of it is easily crackable anyway. It's more of an annoyance to the person who comes later trying to fix the spreadsheet problems.]

If you're just unlocking it, and that's it, then yeah, the VBA given is fine.
__________________

Now offering online seminars, live seminars, and everything else under the sun for actuarial exams.
Reply With Quote
  #5  
Old 07-23-2010, 08:50 AM
spencerhs5's Avatar
spencerhs5 spencerhs5 is offline
Member
 
Join Date: Jan 2007
Posts: 1,048
Default

Quote:
Originally Posted by campbell View Post
One question that I would ask is why would you want it password-locked at all? [I find password-locking to be obnoxious; and much of it is easily crackable anyway. It's more of an annoyance to the person who comes later trying to fix the spreadsheet problems.]

If you're just unlocking it, and that's it, then yeah, the VBA given is fine.
What do you do when you have to give the file to somoene who you anticpate might have very little computer skills but think that it would be a good idea to try and change/personalize a sheet.
Reply With Quote
  #6  
Old 07-23-2010, 08:52 AM
Abused Student's Avatar
Abused Student Abused Student is online now
Member
SOA
 
Join Date: Feb 2007
Location: The Eighth Circle of Hell
Favorite beer: Cold and lots of it
Posts: 35,871
Default

Quote:
Originally Posted by campbell View Post
One question that I would ask is why would you want it password-locked at all? [I find password-locking to be obnoxious; and much of it is easily crackable anyway. It's more of an annoyance to the person who comes later trying to fix the spreadsheet problems.]

If you're just unlocking it, and that's it, then yeah, the VBA given is fine.
I have spreadsheets locked for people down the line to use that I do not want them messing with the formulas. Reserves worksheets and stuff where they only get certain inputs. I have a button to unlock a sheet and another to relock it.
__________________
GAME ON!!!!!!! Let your ness show. Join the D&D fun. Started but applications still accepted


Officially assigned the role of Dictator, 9/30/09. Bow to my whims.
Reply With Quote
  #7  
Old 07-23-2010, 08:59 AM
campbell's Avatar
campbell campbell is offline
Mary Pat Campbell
SOA AAA
 
Join Date: Nov 2003
Location: NY
Studying for Japanese
Favorite beer: Murphy's Irish Stout
Posts: 36,298
Blog Entries: 5
Default

There are two possibilities here:

1. Person you're giving the spreadsheet knows what they're doing. In which case, they can unlock it, password or no. There are Excel password crackers all around the place. You're just making them waste their time.

2. Person doesn't know what they're doing. Locking sans password generally will deter these folks. [I use this all the time... the point is to prevent accidental changes. Deliberate changes, I'm not going to try to stop.]

If you need something super-secure, you shouldn't be doing it in a spreadsheet. There are no real controls.
__________________

Now offering online seminars, live seminars, and everything else under the sun for actuarial exams.
Reply With Quote
  #8  
Old 07-23-2010, 09:02 AM
Abused Student's Avatar
Abused Student Abused Student is online now
Member
SOA
 
Join Date: Feb 2007
Location: The Eighth Circle of Hell
Favorite beer: Cold and lots of it
Posts: 35,871
Default

Quote:
Originally Posted by campbell View Post
There are two possibilities here:

1. Person you're giving the spreadsheet knows what they're doing. In which case, they can unlock it, password or no. There are Excel password crackers all around the place. You're just making them waste their time.

2. Person doesn't know what they're doing. Locking sans password generally will deter these folks. [I use this all the time... the point is to prevent accidental changes. Deliberate changes, I'm not going to try to stop.]

If you need something super-secure, you shouldn't be doing it in a spreadsheet. There are no real controls.
I am dealing with #2 for the most part. Actually some are more in between the two, know just enough to cause all kinds of problems.
__________________
GAME ON!!!!!!! Let your ness show. Join the D&D fun. Started but applications still accepted


Officially assigned the role of Dictator, 9/30/09. Bow to my whims.
Reply With Quote
  #9  
Old 07-23-2010, 09:12 AM
ADoubleDot's Avatar
ADoubleDot ADoubleDot is offline
Member
 
Join Date: Nov 2007
Location: Slightly Dusty South
Studying for the rest of my life
Posts: 35,661
Default

Here is a macro for doing it when you don't know the password. Seriously, excel passwords are stupid.
__________________
def no_one(the_spanish_inquisition):

**** Juan.
Reply With Quote
  #10  
Old 07-23-2010, 09:13 AM
campbell's Avatar
campbell campbell is offline
Mary Pat Campbell
SOA AAA
 
Join Date: Nov 2003
Location: NY
Studying for Japanese
Favorite beer: Murphy's Irish Stout
Posts: 36,298
Blog Entries: 5
Default

The biggest problem is being the person who has to maintain the spreadsheet after the originator left.

Seriously, locking without password generally will keep people messing with formulas accidentally. If they don't have the discipline not to mess with stuff you tell them not to mess with, sounds like you've got other issues going on. Because they will mess with something, password-locking or no.
__________________

Now offering online seminars, live seminars, and everything else under the sun for actuarial exams.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 11:03 AM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
*PLEASE NOTE: Posts are not checked for accuracy, and do not
represent the views of the Actuarial Outpost or its sponsors.
Page generated in 0.22853 seconds with 7 queries