Protecting a VBA project

P

PatrickS

Excel 2007 is turning out to be a pain in the neck, at least where the new
file formats are concerned. Users keep on saving the files in xlsx format
even though the files concerned contain macros. There have been indications
that Excel may be selecting this format by default, but we have not yet
determined the reason why this is happening.

In any case, one possible option I'd like to offer to users is a tool that
will re-import code back into the file and then protect the project. I
realise that the password protection is weak, but this is more to do with
stopping everyday users mucking about with aspects of the file that they
should be leaving alone than protecting any intellectual property.

Is programmatically protecting a VBA project possible from within either
Excel or an external application? If so how I would I go about doing so?
 
J

Jon Peltier

Except via SendKeys, which is kind of shaky itself. I have no code, but
Google could help find it.

- Jon
 
P

Peter T

I've done some work with an app that does the following

- Open the project with known password
- Add a new password or change a password and lock
- Remove password entirely and unlock a project

It can process multiple files as a batch process, eg open locked project,
amend code, and save.

It doesn't use SendKeys though it does use API methods to read and write to
the various project properties dialogs (which do not need to be visible or
'on top' unlike SendKeys equivalent). Files are opened and processed in an
automated instance.

This has been in "occasional" development for quite a while, seems to work
quite well, at least until I change something!. It's too much to post but if
interested I'll forward.

Regards,
Peter T
 

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