Hiding the Code

You cannot stop users from seeing a standard workbook's name, or an Add-in's name, in the Project Explorer window. However, you can stop users from expanding the workbook's name, or Add-in's name, to view the component modules and user forms and the code they contain.

You prevent access to your code by putting a password on the VBA project. Select the project and use Tools O <ProjectName> Properties (where <ProjectName> is the name of your particular project), or right-click the project in the Project Explorer window and click <ProjectName> Properties, to see the screen shown in Figure 17-1.

Figure 17-1

After you have entered the password and confirmed it, click OK and save the file. To see the effect, close and reopen the file. The file has been password-protected and cannot be expanded unless you supply the password. You are prompted for the password when you try to expand the project.

It is a common misconception that Excel's passwords cannot be broken. There are programs available that can decipher file, workbook, and worksheet passwords, as well as the VBA project passwords for all versions of Excel. Since the introduction of Excel 97, the workbook file password has proven a difficult nut to crack if it contains more than just a few characters. Unfortunately, this password is useless to developers who want users to be able to open their files and actually use them.

0 0

Post a comment