unprotecting modules

M

mike allen

I have my VBAproject protected from viewing my code. I want to write a
macro that will unprotect it so I can delete some other modules. I have
tried:

sub unprotectproject()
ThisWorkbook.VBProject.vbcomponents.Unprotect Password:="ok"
end sub

it doesn't work, though. anyone know the answer? Thanks, Mike Allen
 
P

Peter T

Unless you have some method to replace the password in the closed file
(which is what the crackers do) the only way (AFAIK) is with SendKeys.
Search "Unlock VBAProject SendKeys" in this ng.

Regards,
Peter T
 
P

Peter T

I wasn't thinking, even if you could replace the password in the closed file
it'd still be locked. I doubt you'd want to use the unreliable SendKeys
approach and risk exposing your project.

Peter T
 
G

gimme_this_gimme_that

The solution I'd recommend is to store proprietary code and worksheets
in an Excel Add-In.

Alternatively you could import your VBA modules on start up and export
them on exiting.

See : http://www.cpearson.com/excel/vbe.htm for tips on importing and
exporting modules.
 
M

mike allen

what i was planning was to have one module contain code that deletes other
modules that contain valuable code. though protected, code can certainly be
run, as i do this all the time. if i could unprotect the modules while
running this code, i could then delete the other modules (i have the code
for this) and have just the output void of the valuable code. of course, i
would save it as something else. i can certainly unprotect sheets, so it
seems like modules would be available, too. sheets("sheet1").unprotect
password:="ok"

i'll look into the Add-In and export/import as suggested. thanks, mike
allen
 

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