exceldllexportsource-code-protectionvba

How to save VBA code to DLL library?


For security purpose, I want to save my macros from VBA in Excel workbook to DLL library file I'd be calling from the file later.

This way it is possible to deploy any version of my macros to company's PCs but noone would ever see the real code behind it.

How is this possible? I've read on converting to C++ and creating DLL. Is there any step-by-step solution for this?


Solution

  • You can protect your VBA, code by converting it to a password-protected XLA and obfuscating the code. but the password security is weak. Its easy to make the XLA work with all Excel versions.

    An easy alternative is to convert to a compiled VB6 Automation addin. Security is good, its easy to convert, it will handle both UDFs and Command addins. But it won't work with Excel 2010-64 or early versions of Excel like XL 2000. You will need a VB6 compiler, which can be hard to find.

    A harder alternative is to convert to .NET. If you use one of the many obfuscators then security is reasonable. Performance will be poor unless you use one of the tools that allow .NET access via the XLL interface, such as Excel DNA or Addin Express. 64-bit capability is also available.

    If performance and security is critical you would need to convert to a C++ XLL, but this is hard work when coming from VBA.