16

Now that I know that there is an easy workaround to the standard way of locking and password-protecting VBA code, I'd like to move on to more effective ways of protecting code. I am to deliver an Excel-based tool to a client, but would like something more than simple annoyance-type protection that will only deter the laziest of hackers.

Are there any options in Excel-VBA, or do we really have to compile a separate application and forget about our Excel-based interface?

Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188
  • 1
    If you are looking for VBA obfuscater, I'd suggest checking out a tool call VBASH. IMHO it is better than CrunchCode and Obfu-VBA, and definitely better than password protection. https://www.ayedeal.com/vbash – YeP Mar 07 '19 at 00:09

4 Answers4

8

The easiest and most efficient way is to move your VBA code to a VB6 compiled Com/automation addin.

Or you may want to consider a .Net (with obfuscator) solution if performance is not important.

Charles Williams
  • 23,121
  • 5
  • 38
  • 38
  • 1
    +1. I was going to use the com approach when I looked at varrious methods of protecting an addin I considered commercialising. It was clearly the most secure option. And I second that obfuscation can be very effective – brettdj Oct 26 '11 at 10:19
3

Practically, VBA obfuscators do not protect VBA code because they leave the structure of the algorithm unchanged, which can be traced back to the original algorithms which can then be recovered.

Converting your VBA code to VB6 means your application will be limited to 32bit Excel (VB6 doesn’t have a 64-bit version) and it can be decompiled by VB decompilers such as https://www.vb-decompiler.org/

Converting your VBA code to VB.NET isn't a perfect solution either, as .NET has a ‘reflection’ mechanism which can convert the compiled code of .NET assembly into the original source code.

You can convert your VBA code to C/C++, which would be a very effective form of protection, but since C/C++ and VBA are very different programming languages, the conversion of VBA code to C/C++ is difficult, error prone, and generally not worth the huge amount of time and effort that it takes.

There is a tool called VbaCompiler for Excel (http://vbacompiler.com) which converts the VBA code to C language code and then compiles it into a DLL. The level of protection this tool claims to provide is similar to that of converting your VBA code to C/C++ but without the massive amount of manual work that is required for such a process.

NikoDeem
  • 51
  • 3
2

Another Trick is to write the code against a excel object in Access then make the access file in to a .mde http://www.blog.methodsinexcel.co.uk/?s=Access+MDB Poor, but cheep ;-)

Ross
  • 300
  • 1
  • 8
  • The given link is broken, try this http://www.databasedev.co.uk/microsoft-access-mde.html. Looks promising. – S Meaden Jan 11 '17 at 22:50
2

No need to convert to another language - you should be able to obfuscate most of your VBA code through www.vbsobfuscator.com [Note: Links to archive.org]

Trashman
  • 1,424
  • 18
  • 27
Bosco
  • 935
  • 10
  • 18
  • This is now a dead Link taken over by a site squatter with dubious website links. – Trashman Jan 11 '17 at 22:29
  • I could not find a current version, so I edited the post to link to the most recent working archive.org copy of the site. I did not test that the actual obfuscator feature of the site still works, however. – Trashman Jan 11 '17 at 22:50