Creating an addin from an Excel macro

Pages in this article

  1. Preparations
  2. Book or add-in
  3. Menus
  4. Toolbars
  5. Limit access
  6. Protect code
  7. Initialise
  8. Save Settings
  9. UI Languages
  10. Setup
  11. Conclusion

Protecting Your Code

Generally spoken there are two important reasons why VBA code would be protected:

The Visual Basic Editor offers the option to lock a project for viewing. From within the VBE, choose Tools, VBAProject Properties. Select the second tab and check the "Lock Project for Viewing" checkbox:
The protection tab of the VBAProject properties dialog
The protection tab of the VBAProject properties dialog.

After that, optionally enter a password.

Unfortunately, the level of protection this offers is bad. One can download small programs from internet that remove the password in the blink of an eye and with a simple HEX editor, one can do the same manually by simply replacing three or four characters inside the file.

The only really secure way to protect the code is by NOT using VBA, but rather by building the application in e.g. VB6 or by creating a com addin using Office developer edition.