How to Protect VBA Code
Microsoft's Visual Basic for Applications (VBA) is the standard language for writing programs to automate functions and tasks in Microsoft Office. Understand how to protect VBA code so others can't sabotage or steal your macros. Open the...
Method 1 of 3:
Secure VBA Code with a Password
-
How to Protect VBA Code Picture 1
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.
How to Protect VBA Code Picture 2
- Select "Project Properties" in the "Tool" menu within the Visual Basic Editor.
-
How to Protect VBA Code Picture 3
Go to the "Protection" tab. -
How to Protect VBA Code Picture 4
Select the "Lock Project for Viewing" check box. If you don't check this box, you won't hide your code. -
How to Protect VBA Code Picture 5
Create and confirm your desired password in the indicated boxes. -
How to Protect VBA Code Picture 6
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 of 3:
Hide VBA Code in a Read-Only File with Access 2007
-
How to Protect VBA Code Picture 7
Go to the "Database Tools" tab. -
How to Protect VBA Code Picture 8
Find the "Database Tools" group. -
How to Protect VBA Code Picture 9
Select "Make ACCDE." -
How to Protect VBA Code Picture 10
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 of 3:
Protect Your VBA Code by Making an Add-In
-
How to Protect VBA Code Picture 11
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.) -
How to Protect VBA Code Picture 12
Copy your VBA code into the Visual Basic Editor of that empty file. -
How to Protect VBA Code Picture 13
Open the "Macros" window, usually stored under "Tools." -
How to Protect VBA Code Picture 14
Test your code again, which debugs it. -
How to Protect VBA Code Picture 15
Remove anything added to the empty file by your test. -
How to Protect VBA Code Picture 16
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.) -
How to Protect VBA Code Picture 17
Compile your code. (In the Visual Basic Editor, look under the "Debug" menu and select "Compile VBA Project.") -
How to Protect VBA Code Picture 18
Save a copy of the file in a standard file type. -
How to Protect VBA Code Picture 19
Go to "Tools" in the Visual Basic Editor, then select "Project Properties." -
How to Protect VBA Code Picture 20
Select the "Protection" tab. -
How to Protect VBA Code Picture 21
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.) -
How to Protect VBA Code Picture 22
Open the "Save As�" or "Save a Copy" dialog box. -
How to Protect VBA Code Picture 23
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.
-
How to Protect VBA Code Picture 24
Quit and reopen Microsoft Office. Your add-ins should now be usable.
5 ★ | 2 Vote
You should read it
- How to save Excel file contains VBA Macros code
- How to save web pages as PDFs on iPhone and iPad
- What is the Code Kill Monsters to Save Princess used for?
- How to save files to multiple folders on the web browser
- Steps to save Email as PDF
- How to save AI file in Adobe Illustrator to JPG and other image formats
- Latest Code Kill Monsters To Save Princess
- How to Save a Microsoft Word Document
- How to save Zip file to iPhone or iPad
- 3 How to rotate a PDF file and save it as the simplest new file
- List of some types of files that are potentially dangerous on Windows
- How to fix the error can not save Excel file
Maybe you are interested
Windows 11 is about to support content search in local video and audio files
How to change your Google account profile picture
Scammers are using fake Windows updates to steal users' files
Why does opening MOV file have no image? How to fix?
How to share files and send large files online quickly and easily
How to create a personal profile online