Search : in
By :

Excel Macro; Adding Password

Last answer on Sep 9, 2009 12:12:12 pm BST zeromaim, on Jul 29, 2008 3:51:57 pm BST 
 Report this message to moderators

Hello,

Hope you anyone can help me with this...

I need to create a macro that unlocks a password-protected sheet with password "password", do some instruction, then locks it again with same password.

Thanks in advance for any assistance.

zero

Configuration: Windows XP
Internet Explorer 7.0

Best answers for « Excel Macro; Adding Password » in :
Inserting an animated gif in Excel ShowInserting an animated gif in Excel To insert an animated gif image in an Excel spreadsheet, you must insert the image into a control. To insert the control, go to the View menu/Toolbars/Control Toolbox Activate the first button Design...
Adding a VBA CommandButton with its respective the code ShowAdding a VBA CommandButton with its respective the code Paste these two sub in a general module (Module1 for example). Sub CreateButton() Dim Obj As Object Dim Code As String Sheets("Sheet1").Select 'create button ...

1

Ivan-hoe, on Aug 5, 2008 5:45:49 pm BST
  • +2

Hello zero,
the syntax is quite simple

ActiveSheet.Unprotect ("MyPassWord")
'instructions
ActiveSheet.Protect ("MyPassWord")

for more details, I suggest you type "worksheet.protect" and "worksheet.unprotect" in the help file of visual basic editor.
Ivan

Reply to Ivan-hoe

2

zeromaim, on Aug 6, 2008 12:22:47 pm BST
  • +1

Hi Ivan,

Thanks for this, and other one as well.
I'm not actually a programer. I self-studied excel and i'm good at using formulas.
I just recently learn about macro and I used to just for recording to eliminate the circular ref error with formulas.
I was glad to have found this site and have read one of your response.

Thanks,

Anton

Reply to zeromaim

5

DaveyBoy, on Oct 7, 2008 5:29:39 pm BST

The ActiveSheet.Protect ("MyPassWord") works, but what if you want the set certain "abilities" to True when assigning the password as in the following code.

ActiveSheet.Protect ("MyPassWord") DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True

This errors out when the Macro is ran. Is there a different Syntax for a case like this?

Reply to DaveyBoy

6

Ivan-hoe, on Oct 8, 2008 11:46:29 am BST
  • +1

Hello,
try this syntax :

ActiveSheet.Protect PassWord:="MyPassWord", DrawingObjects:=True,  _ 
Contents:=True,  Scenarios:=True, AllowSorting:=True, AllowFiltering:=True,  _ 
AllowUsingPivotTables:=True 

Ivan

Reply to Ivan-hoe

8

 Josh, on Sep 9, 2009 12:12:12 pm BST

Hey Ivan valuable info on your post. Thanks pal.

Reply to Josh

3

zeromaim, on Aug 8, 2008 12:30:41 pm BST

Thanks Ivan.

How do I change the status of this topic to "resolved"?

Anton

Reply to zeromaim

4

aquarelle, on Aug 8, 2008 8:30:12 pm BST

Hi,
Go to the top of your thread (to the right part), and check the case "solved" after click on "OK"
Best regards "Pour trouver une solution � ses probl�mes, il faut s'en donner la peine."

Reply to aquarelle

7

Greg, on Jun 26, 2009 5:09:26 pm BST

Thanks Ivan!

Reply to Greg