Securing VBA code in Office

Most of us know that .dll’s are the only real option if security is a genuine issue, but I think the following might be a possible (bodge) solutions for those who many not have VB, and need better security for their VBA code. Anyway, I was looking at this site:

Tech Net – Office 2000/Visual Basic Programmer’s Guide

Chapter 17 deals with security. My lighting fast brain crawled in to action and I thought I’d try something.

Now according to this info:

In Access, you can save an .mdb or .adp file as a file type that contains only compiled VBA code without the source code.

These files are called .mde file and most of us will have worked with these before, or at least heard of them. I didn’t know the code was compiled though. Doing a little bit of goggling it seems that decompiling is available, but that the VBA code remains compiled, i.e. forms and report are easy to decompile, but the VBA remains compiled good news.

See where we are heading? You can call this .mde code from you Excel/Word etc VBA, and your more sensitive VBA code can be kept in a complied- harder to get at – .mde file. In theory it’s a bit like putting your code in a proper .dll it’s compiled code. Which kinda begs the question, why can you do this with all our VBA?

Here is an example I’ve put it into a UDF, and it runs in such a way as to be dog slow, but it could be implemented better, or if the situations was different the performance hit would be less noticeable I’m sure you’ll get the idea. I’ve inculed the orginal mdb, and you can do all the other passwording etc to this mde before making it a mde. I’ve also chnaged the file extention to change the icon, whcih is of little importance.

So, it’s Heath Robison, it’s far from ideal but it might be useful to someone; oneday! A nice little idea I though”¦Â 

Related posts:

  1. P -code??????
  2. Free VBA code library!!!
  3. Is Managed Code Slower Than Unmanaged Code?

Comments

  1. vasw says:

    excellent tip…. however please note that .MDB to .MDE conversion can only be done in Acess2007 and onwards… not in Access2000,2002,2003 etc

    http://technet.microsoft.com/en-us/library/cc178973.aspx
    find on this page “New Feature in Office Access 2007″

  2. Ross says:

    Hi vasw,

    Thanks for the feedback. I thnk it’s a neet trick too, but judge that your the first person to comment on this post in 2 years I guess we are the only ones!!!!

    BTW, it’s not the case that you can only make .mde files in Office 2007. You can do this in 2000, 2002 and 2003. – close all db and then go to the tools menu, and then to make mde!!! simple!

    good luck!

  3. bruce says:

    Genius. I love the changing the file extension to mask the mde. I will use this over spending $250+ on a VBA compiler or switching to VSTO. Thank very much!

Submit a Comment