If your workbook contains VBA code, you may wish to use a password to prevent others from viewing or modifying your macros. To apply a password to the VBA code in a workbook, activate the VBE (Alt+F11)
and select your project in the Projects window. Then choose Tools xxxx Properties (where xxxx corresponds to your Project name). This displays the Project Properties dialog box.
In the Project Properties dialog box, click the Protection tab (see Figure 2-21). Enable the Lock Project for Viewing check box and enter a password (twice). Click OK and then save your file. When the file is closed and then reopened, a password will be required to view or modify the code.
VflAProject Prof act Propertiss
C Lodi pf[>je:e far p«iAGfd to 'Jtvi project piopioes ii-SS^Qfd
Figure 2-21: Protecting a VBA project with the Project Properties dialog box.
Caution It's important to keep in mind that Excel is not really a secure application. The protection features, even when used with a password, are intended to prevent casual users from accessing various components of your workbook. Anyone who really wants to defeat your protection can probably do so by using readily available password-cracking utilities (or by knowing a few "secrets").
Was this article helpful?