Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

unprotect VBA project with code

272 views
Skip to first unread message

zSplash

unread,
Sep 1, 2004, 4:09:37 PM9/1/04
to
How do I programmatically unprotect a VBA project? That is, I have copied
my Normal.dot as an addin, and now want to programmatically re-name the
addin (so that I can use VBE.VBProjects(x).Name to modify the code). I
tried:

Documents.Open FileName:="C:\newAddin.dot"
VBE.ActiveVBProject.Unprotect "password"

and get the error 438, Object doesn't support this property or method. Not
to complain, but it seems like I'm going in circles trying to do something
relatively simple. Please help.

TIA


Jezebel

unread,
Sep 1, 2004, 6:30:48 PM9/1/04
to
I don't know that anyone has found a way to do this. Even using oddball
techniques like SendKeys or making API calls to seed the Windows message
queue.

But are you sure that's the problem? You get the 'Project is unviewable'
message on add-ins if the add-in is not actually open (that is you need to
switch to Word's main window and open the add-in file itself). Otherwise the
add-in is loaded and you can execute its code, but you can't view it or
manipulate the code.

"zSplash" <zNOSPAMSplash@ gci.net> wrote in message
news:%23PVbd%23FkEH...@TK2MSFTNGP11.phx.gbl...

Gene

unread,
Sep 2, 2004, 10:13:50 AM9/2/04
to
Try this:

In The Visual Basic Editor select Tools . . . References
Check Microsoft Visual Basic for Applications Extensibility 5.3 (number may
be different depending on your version - I am using office XP)
Click OK
Close the VBE and restart MS Word.

Try your code again.

Hope this helps,

Gene

--

Thanks,

Gene


"zSplash" <zNOSPAMSplash@ gci.net> wrote in message
news:%23PVbd%23FkEH...@TK2MSFTNGP11.phx.gbl...

zSplash

unread,
Sep 2, 2004, 2:59:01 PM9/2/04
to
Thanks for your help, Jezebel and Gene. I should not have said "as an
addin" but "as a template.

The error I get is "Run-time error 50289: Can't perform operation once the
project is protected." What I'm trying to do is 2 things: rename the
locked project and use VBE to edit two lines of code in the locked project.

The project needs to be locked. I guess I'll have to just manually unlock
and rename the project before running the code, and then, after running the
code, go back and lock the project again. Rats.

st.
"Jezebel" <dwa...@heaven.com.kr> wrote in message
news:%23$ahWNHkE...@tk2msftngp13.phx.gbl...

0 new messages