Table of Contents
This updated guide examines How to Protect Vba Code and organizes the essential facts, background, and practical takeaways in clear American English.
Method 1
Secure VBA Code with a Password
Open the Visual Basic Editor, usually found under "Macro" in the "Tools" menu. (In Access, you may need to be in the database window to reach the editor, depending on your computer set-up.)
- Select "Project Properties" in the "Tool" menu within the Visual Basic Editor.

- Select "Project Properties" in the "Tool" menu within the Visual Basic Editor.
Go to the "Protection" tab.
Select the "Lock Project for Viewing" check box. If you don't check this box, you won't hide your code.
Create and confirm your desired password in the indicated boxes.
Save, close, and reopen your workbook for the protection to take effect. (In Microsoft Excel 2007 and later, you may need to save as an XLSM file for your code to work.)
Method 2
Hide VBA Code in a Read-Only File with Access 2007
Go to the "Database Tools" tab.
Find the "Database Tools" group.
Select "Make ACCDE. "
Save the ACCDE file with a separate name from the original file. That ACCDE file is a read-only file type, so you need to keep the original file, too, to be able to make any changes.
Method 3
Protect Your VBA Code by Making an Add-In
Create an empty Office file of the type that will use your code. (For example, if your code works with MS Excel, create an Excel file.)
Copy your VBA code into the Visual Basic Editor of that empty file.
Open the "Macros" window, usually stored under "Tools. "
Test your code again, which debugs it.
Remove anything added to the empty file by your test.
Add a description to the macro that will run in your add-in. (You may need to select macro "Options" to be able to insert the description.)
Compile your code. (In the Visual Basic Editor, look under the "Debug" menu and select "Compile VBA Project.")
Save a copy of the file in a standard file type.
Go to "Tools" in the Visual Basic Editor, then select "Project Properties. "
Select the "Protection" tab.
Activate the "Lock Project for Viewing" check box. (You may also need to set a password, depending on the specific file type you're working with and your settings for MS Office and your computer.)
Open the "Save As?" or "Save a Copy" dialog box.
Access the drop-down menu and change the file type to the appropriate type of add-in.
- Save a Microsoft Word add-in as a DOT file, a document template. (If you want the add-in to run when you start Word, save it in the Word Startup folder.)
- Save a Microsoft Excel add-in as an XLA file.
- Save a Microsoft Access add-in as a MDE file, which will protect the VBA code. (Microsoft Access add-ins can also be saved as MDA files, but this doesn't hide the code.)
- Save a Microsoft PowerPoint add-in as a PPA file which will hide the VBA code and leave it unable for anyone other than you to access it or edit it.
Quit and reopen Microsoft Office. Your add-ins should now be usable.
FAQ
What is How to Protect Vba Code about?
It provides a structured overview of file, explains the main context, and highlights practical takeaways for readers.
Why does this topic matter?
Understanding the main concepts helps readers evaluate the issue, avoid common mistakes, and make better-informed decisions.
How should readers use this information?
Use the guidance as a practical starting point, confirm details that may have changed, and follow current product, safety, or security recommendations.
Reader Comments 0
Sign in with email or Google to join the discussion.