I've spent some time writing an Excel Macro that is potentially worth money to a lot of companies.
How can I lock down the macro to prevent people seeing the source / forwarding to other people?
Thanks
I've spent some time writing an Excel Macro that is potentially worth money to a lot of companies.
How can I lock down the macro to prevent people seeing the source / forwarding to other people?
Thanks
Protect/Lock Excel VBA Code:
When we write VBA code it is often desired to have the VBA Macro code not visible to end-users. This is to protect your intellectual property and/or stop users messing about with your code. Just be aware that Excel's protection ability is far from what would be considered secure. There are also many VBA Password Recovery [tools] for sale on the www.
To protect your code, open the Excel Workbook and go to Tools>Macro>Visual Basic Editor (Alt+F11). Now, from within the VBE go to Tools>VBAProject Properties and then click the Protection page tab and then check "Lock project from viewing" and then enter your password and again to confirm it. After doing this you must save, close & reopen the Workbook for the protection to take effect.
(Emphasis mine)
Seems like your best bet. It won't stop people determined to steal your code but it's enough to stop casual pirates.
Remember, even if you were able to distribute a compiled copy of your code there'd be nothing to stop people decompiling it.
Just like you can password protect workbooks and worksheets, you can password protect a macro in Excel from being viewed (and executed).
Place a command button on your worksheet and add the following code lines:
First, create a simple macro that you want to protect.
Range("A1").Value = "This is secret code"
Next, click Tools, Then VBAProject Properties...
Click Tools, VBAProject Properties...
Enter a Password Twice
Click OK.
Save, close and reopen the Excel file. Try to view the code.
The following dialog box will appear:
Password Protected from being Viewed
You can still execute the code by clicking on the command button but you cannot view or edit the code anymore (unless you know the password). The password for the downloadable Excel file is "easy".
Dim password As Variant password = Application.InputBox("Enter Password", "Password Protected") Select Case password Case Is = False 'do nothing Case Is = "easy" Range("A1").Value = "This is secret code" Case Else MsgBox "Incorrect Password" End Select
Result when you click the command button on the sheet:
Password Protected from being Executed
Explanation: The macro uses the InputBox method of the Application object. If the users clicks Cancel, this method returns False and nothing happens (InputBox disappears). Only when the user knows the password ("easy" again), the secret code will be executed. If the entered password is incorrect, a MsgBox is displayed. Note that the user cannot take a look at the password in the Visual Basic Editor because the project is protected from being viewed
You can check out this new product at http://hivelink.io, it allows you to properly protect your sensitive macros.
The Excel password system is extremely weak - you can crack it in 2 minutes just using a basic HEX editor. I wouldn't recommend relying on this to protect anything.
I wrote an extensive post on this topic here: Protecting Code in an Excel Workbook?
you can set a password to your vba code but this can be quite easily broken up.
you can also create an addin and compile it into a DLL. See here for more information. That's at least the most secure way to protect your code.
Regards,
The modern approach is to move away from VBA for important code, and write a .NET managed Add-In using c# or vb.net, there are a lot of resources for this on the www, and you could use the Express version of MS Visual Studio
Generate a protected application for Mac or Windows from your Excel spreadsheet using OfficeProtect with either AppProtect or QuickLicense/AddLicense. There is a demonstation video called "Protect Excel Spreedsheet" at www.excelsoftware.com/videos.