Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 803
Skuta Avatar asked Feb 08 '11 14:02

Skuta


People also ask

How do I create a DLL in Excel VBA?

To do that you need to attach the VB.NET / Visual Studio debugger to the running EXCEL. EXE process, place a breakpoint on the first executable statement, execute the failing VBA code (which calls your dll), and then you can step through the VB.NET code and inspect what VBA has been giving you.

How do I register a DLL in VBA?

Excel workbook solution Press the Select DLL button, find the location of the DLL file on your hard disk and select it. After selecting the DLL file you have two choices: you can either register or unregister the DLL file by pressing the buttons Register DLL and Unregister DLL correspondingly.


1 Answers

First off, let me warn you against this in general. We did this once with a corporate app and the time it took to port was approximately the same as the time it took to write the app originally. A step-by-step guide won't exist for this because you're basically rewriting the app from scratch.

Secondly, not everything your Excel VBA can do is necessarily available in COM, or XLL. The events available are different; in the case of XLL there are entirely new structures to use for all of the data types. In COM there are no UDFs; in XLL there are no macro actions. You will no longer be able to attach code to worksheets (only Excel sessions) and the install procedures are much more complex. I would spent a long time researching what your VBA does exactly before embarking down one particular path.

It depends how large your app is, but I would encourage you to invest the money in getting watertight licenses drawn up and doing some basic code obfuscation (as per the original comments) rather than starting from scratch with a different architecture.

like image 133
Chris Rae Avatar answered Sep 22 '22 13:09

Chris Rae