I don't think so. AFAIK, the vba object model does not expose the vbe for editing, which is probably a good thing. SendKeys might work, but it would be very unreliable. You'd have to embed the password in code, exposing it to anyone who might find the code unlocked by the last person who unlocked it. You cannot rely on db shutdown to run any code that would re-lock it on exit.
Why not just either
- provide the password to those whom you want to expose the code to so they can unlock it for viewing
- dump the code to a document that only they can see/open
- make the db an mde or accde?
There seems to be exposure to the vb project, but it's properties are read only - not the code itself.
https://msdn.microsoft.com/en-us/lib.../ff195749.aspx
Last edited by Micron; 11-09-2016 at 10:19 AM.
Reason: correction
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.