vba project properties via code

T

Tim Rush

I have a rather large group of files to modify. The vba modules of each are
'nearly' identical, and I need to add or remove code from each one. I have
the code in place to modify them, but each one has their vba project password
protected (al with the same passord).
How do I pass the password to the project from within my code to unlock
those other projects before I modify them. (Note I do not wish to remove the
protection, just open the projects, modify and get out again.)
If I open them and unlock manually, it could take me days, and the point of
my project is to do this in a matter of minutes, to force them all to use the
same external code for their processing.
Thanks!!
Tim
 
B

Bob Phillips

It can be done, but it involves the use of SendKeys which isn't too stable.

This is an example, but you may need to tune it

With Application
.SendKeys "%{F11}", True ' VBE
.SendKeys "^r", True ' Set focus to Explorer
.SendKeys "{TAB}", True ' Tab to locked project
.SendKeys "~", True ' Enter
.SendKeys "password"
.SendKeys "~", True ' Enter
End With

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
S

stefan onken

hi Tim,
you can use SendKeys to unlock vba protection

pw = "password"
SendKeys "%{F11}%xi" & pw & "{ENTER}{TAB 6}{ENTER}", True

don`t know if this still works with XL2007.

stefan
 
T

Tim Rush

Great... Took me a while to figure what was happening, but I mangaed to use
it. First time using SendKeys. I can see its instability, but if careful,
it could be powerful too.
Since I found no way to tell it which workbook to tab through, I cycled it
through all of them. The active workbook is not always the first one listed.

Thanks for the help!
 
B

Bob Phillips

I would have closed all of the others apart from the code workbook, it
should be more predictable then.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top