Unlock Protected VBAProject via code

E

ExcelMonkey

Is there a way to unlock a VBAProject via code other than using the SendKey
method?

The reason I ask is that I have a large number of file to go through which
have projected VBAProjects. The users are providing me with the passwords in
advance. I simply want to automate the process

Thanks

EM
 
B

Bob Phillips

You would still need to know the password, it is not a cracking method

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
 
E

ExcelMonkey

Correct me if I am wrong Bob but isn't the issue with this method that you
really don't know (in advance) how many TABs you will have to press to
navigate down the items in the Project window? It's obvious when you are
looking at the Project window once teh IDE is open.

I am assuming this is an issue as the items will be a function of all the
Add-ins you have loaded in your Excel and the files you current have open on
your computer.

Thanks

EM
 
E

ExcelMonkey

One last question Bob. Would this be any easiser using VB (.Net)? Or is
this irrelevant as there is not any exposure to the Object model period?

Thanks

EM
 
B

Bob Phillips

Yes, you are absolutely correct, which is why I said that it needs tuning.

It isn't failsafe, Sendkeys never is. Personally, I am lost as to why anyone
needs this.
 
B

Bob Phillips

I can't say for sure, Net is a new world for me, but I cannot see how it
would be.

Maybe you could iterate through the projects in the VBIDE, sort them, and
then work out where in the list the target project is.
 

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