Excel VBA code to unlock developer password

macca_18380

New Member
Joined
May 15, 2024
Messages
22
Office Version
  1. 365
Hi and thank you in advance,

Is it possible to have create a VBA code that unlocks a password set in developer?

Thank you
Michael
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi Michael
This forum doesn't support or provide information regarding password manipulations, but yes it is possible. !
 
Upvote 0
Thank you for your response and i'm sorry, i should have been more clear. It's a password that i know and have set, i want to run a macro that unlocks my password, unhides all sheets so that calculations and updates can take place, and then when the calculation is finished to re-input the password and protect the workbook again. Is that possible to discuss on this forum?
 
Upvote 0
There isn't really a concept of unlock and re-lock developer, I think you mean protect the workbook structure.
Try this:
(Note: ThisWorkbook is the workbook with the code in it. If that is not the case perhaps use ActiveWorkbook)
VBA Code:
Sub ProtectUnprotect()
    ThisWorkbook.Unprotect Password:="1234"
    ' -------------
    ' do something
    ' -------------
    ThisWorkbook.Protect Password:="1234", Structure:=True
End Sub
 
Upvote 0
Hi Alex,

Thank you for your suggestion, this is my fault, i'm not being clear enough. I ran the macro as you suggested and afterwards i hit right click on the tab to view code for the particular sheet i am working on and I was met with the VBA Project Password box, this is the password box i'm trying to enter my password into...any ideas on how to do this?

Thank you
Michael
 

Attachments

  • Screenshot 2024-05-28 134540.png
    Screenshot 2024-05-28 134540.png
    15.8 KB · Views: 6
Upvote 0
How did you add the code I gave you ? You would have had to enter the password to enter the code.
There should be nothing your macro needs to do that requires the VBA project to be unlocked.
If you want to change the code just manually unlock it by entering the password.
 
Upvote 0
How did you add the code I gave you ? You would have had to enter the password to enter the code.
There should be nothing your macro needs to do that requires the VBA project to be unlocked.
If you want to change the code just manually unlock it by entering the password.
I added it into a module, changed the password to my password, and assigned it a button and ran the macro. Afterwards i ran my calculation macro but i got this error which i presume has something to do with a tab that i have hidden. I have hidden tabs in the workbook by using the xlveryhidden option in the properties section of the VBA Project. So ideally i need to automatically unlock and change the Visible option to xlsheetvisible for all hidden worksheets.
 

Attachments

  • Screenshot 2024-05-28 140647.png
    Screenshot 2024-05-28 140647.png
    38.9 KB · Views: 10
  • Screenshot 2024-05-28 140948.png
    Screenshot 2024-05-28 140948.png
    14.8 KB · Views: 10
Upvote 0
In your macro you'll need to unlock the sheet and unhide the sheet...then rehide it before the sub ends.
VBA Code:
    Sheet14.Unprotect Password:="1234"
    Sheet14.visible = xlSheetVisible
    ' -------------
    ' do something
    ' -------------
    Sheet14.visible = xlSheetVeryHidden
    Sheet14.Protect Password:="1234"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top