PDA

View Full Version : Unlock all VBA projects



theta
07-06-2012, 07:52 AM
I have several (dozens) of VBA projects within the VBE. When I open the trigger workbook, it opens up several other workbooks with their own modular VBA components - this all comes together to form a product.

I need to search all modules for a few hard coded strings that need to be replaced - is there a macro available to quickly unprotect all projects in the VBE?

They all have the same password so I can enter this into the code / inputbox

Any help appreciated, will save me alot of time! I cannot remove the passwords as they are shared, I just need to be able to unlock them when needed with the minimal of fuss.

CodeNinja
07-06-2012, 08:26 AM
are you looking for:

workbooks(index).unprotect

?

theta
07-06-2012, 09:05 AM
Yes but I need a looping code to unprotect all projects in the VBE?

CodeNinja
07-06-2012, 09:21 AM
perhaps something like:

For i = 1 to excel.workbooks.count
workbooks(i).unprotect(password)
next i

Paul_Hossler
07-07-2012, 02:09 PM
is there a macro available to quickly unprotect all projects in the VBE?

If you're looking to unprotect the macros for all the workbooks in your project, then IMHO a program driven way would not be very secure, even if they are all yours and protected with the same password.


It might be worth pulling all the changeable settings, strings, etc. out and putting them in a seperate workbook

Paul

snb
07-08-2012, 03:15 AM
It doesn't make sense to have protected vbaprojects in a developer's environment.
I think it may serve some purpose to have only distributed applications VBAproject-protected.
So make a distinction between a developer's environment and a distribution environment.
In the latter you copy the files from the former and provide them with a protection before distributing.

joecor
07-09-2012, 12:26 PM
perhaps something like:

For i = 1 to excel.workbooks.count
workbooks(i).unprotect(password)
next i

It is not working....