Need to Protect/Hide Macro/Modules


Posted by Carol on October 15, 2001 9:52 AM

First - to "Faster" and "Anon" - thanks for the help in writing the macro to unprotect/sort/protect!

I'm new at macros, and am learning as I go. I have a file that's protected to prevent the user from making changes to the format/formulas/data validation, etc., but allows them to enter data. I've written a few macros to allow them to sort on columns, but I don't know how to prevent the user from looking/editing the macros to see what the password for the file is. Can anybody help me out?

Thank you in advance! You folks are saving me hours of work and frustration!

Posted by Dan on October 15, 2001 10:18 AM

From the Microsoft Web Site, HTH:

You can protect the modules from being viewed by locking the project for viewing, providing a password, and then saving the file normally.

NOTE: By doing this, you will not be able to save a Microsoft Excel workbook down to an earlier format.

To protect a module from being viewed, follow these steps (or the appropriate ones for your version of Excel).

NOTE: The following steps are for Microsoft Excel 97:

In the Visual Basic Editor, click Project Name Properties on the Tools menu, where Project Name is the name of the project that you are protecting.


Click the Protection tab.

Click to select the Lock Project for Viewing check box. Type a password in the Password box, and then type the password again in the Confirm Password box.

Click OK.

On the File menu, click Close and Return To Microsoft Excel.

In Microsoft Excel, click Save.


To view a protected module, follow these steps:
On the Tools menu, point to Macro, and then click Visual Basic Editor.

In the Visual Basic Editor, click the entry for the add-in in the Project pane.

When you are prompted, type the password for the add-in, and then click OK.



Posted by Carol on October 15, 2001 10:47 AM

Dan - you're the best, thank you!

Dan - thank you! It works like a charm.