Temporarily unlock VBAProject password to run code

Sargad_Strut

New Member
Joined
Mar 28, 2014
Messages
44
Hi Experts,

I have a number of workbooks (20+) that are being used by multiple users, and the code is password protected in order to hide sensitive information. Currently, I'm working on implementing a UserForm, that will be the same for all workbooks. The form is be imported on open, and that way I only need to make changes once, instead of doing it for all workbooks one by one. Everything went fine until I password protected the VBA code, which won't allow me to import the form. The solution that comes to mind would be to remove the password, import the form, and then password protect the VBAProject again.

Anyone know if this can be done, or have other suggestions on how to solve this problem? Solutions involning Extensibility are not feasable.

Any help is greatly appreciated.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
If those 20 workbooks share the same VBA I would opt for moving the code to an add-in. Updating an add-in is easier as there is only one file left to update rather than 20. All it takes is replacing the add-in. See: Excel: Building an Excel add-in and Excel: Update An Addin

Hi Jan,

Thank for your quick reply.

The 20 workbooks all contain different code, and also different passwords. The 'centralized' UserForm I am working on will be used as a standardized prompt to enter ODBC-credentials, and I just thought that it would be a nice feature to load it upon open every time, as that could spare me some headache in the future if things change. I was thinking something like this:

VBA Code:
Private sub Workbook_open()

'code to remove password
call loadUserForm
'code to set password again

End Sub

Right now I leaning towards just having control over some of the items on the form externally, but will look into the use of add-ins in any case.

Thanks again!
/Tobias
 
Upvote 0
You could place the userform (and supporting code) in an add-in and create a reference in your other files to this add-in and then show the form from the other workbooks. But I think this adds to the complexity of your project rather than making it simpler.
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,759
Members
449,048
Latest member
excelknuckles

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