How to Hide Modules, Projects and Macros From Users

In Microsoft Office, you might want to hide your Visual Basic for Application (VBA) projects, modules or macros from your end-users to prevent them from tampering with your code. Furthermore, protecting them keeps curious users from accessing classified information, such as passwords, embedded in your code. To prevent your macros from showing up in the "Macros" list, set their scope to "Private." By default, macros and functions are declared as "Public," which means that users will still be able to view code that is hidden within a locked or protected VBA project.


    • 1

      Start the Microsoft Office application that you're using for your VBA project. Press "CTRL+O," select the file that contains your project and then click on "Open."

    • 2

      Press "ALT+F11" to open the Visual Basic Editor (VBE).

    • 3

      Click on the "+" button beside the "Modules" folder in the "Project Explorer" panel to reveal the list of modules in your project.

    • 4

      Double-click on a module to show its code in the editor. Type the following at the beginning of the module:

      Option Private Module

    • 5

      Repeat the previous step for the remaining modules in your project.

    • 6

      Right-click on the name of your VBA project in the "Project Explorer" panel and then select "VBAProject Properties" from the context menu.

    • 7

      Click on the "Protection" tab and then select "Lock project for viewing."

    • 8

      Type your preferred password in the "Password" and "Confirm password" boxes. Take note of your password, or write it down.

    • 9

      Click on "OK." Press "ALT+Q" to close the VBE and return to your document.

    • 10

      Press "CTRL+S" to save your document. For the changes to take effect, close your document and then open it again.

Tips & Warnings

  • Be sure to take note of your password, or choose one that you can easily remember. If you forget your password, it's possible that you may no longer be able to recover your VBA code.
Related Searches


Related Ads

Check It Out

Prep for Black Friday Checklist [Infographic]