Except for setting passwords for your Excel files and worksheets, now you can also password protect VBA codes. In this article, we will show you the method to fulfill this task.
VBA codes in a macro-enabled workbook are certainly very essential to your work. Hence, you need to protect those codes. Among all the protection methods, you can set passwords for the codes. And below are the steps about this task.
Protect VBA Codes
- Open the target file that contains the VBA codes that you need to protect.
- Click the tab “Developer” in the toolbar.
- And then click the button “Visual Basic” in the toolbar. Thus, you have activated the Visual Basic editor. In addition, you can also press the shortcut keys “Alt +F11” on the keyboard to activate the editor.
- Next in the editor, click the button “Tools” in the toolbar.
- And then choose the option “VBAProject Properties” in the sub menu.
- Now in the “Project Properties” window, choose the tab “Protection”.
- Next check the option “Lock project for viewing”.
- After that, input your password into the text box of the “Password”.
- And then input the password again into the text box of the “Confirm password”.
- When you finish all the settings, click the button “OK”.
- After that, click the button “Save” in the toolbar. Or you can also press the “Ctrl + S” on the keyboard to save the file. Thus, you have saves the password in the file.
The Effect of the Setting
Here we will show you the effect of the setting.
- Now close the current file and then open it again.
- Next open the Visual Basic editor. Here you cannot see the codes directly.
- When you try to expand the menu and watch the codes, you will see the “VBAProject Password” window pop up.
- Now input the password into the text box.
- And then click the button “OK”.
Thus, you can expand the menu and see all the codes in the project.
In addition, there still exists another result. In the previous part, if you uncheck the option “Lock project for viewing” in step 7, the result will be a little different. When you open the Excel workbook, you can still see the codes in the project. The difference lies in the VBAProject Properties.
- Click the button “Tool” in the toolbar.
- And then click the option “VBAProject Properties”.
And now, instead of opening the dialog, you will see the “VBAProject Password” window pop up.
- Here input the password and click “OK”. Thus, you can check the project properties.
Therefore, if you need other users to know the codes and hide the properties, you can uncheck the option “Lock project for viewing”. The settings are all depend on your need.
When you want to remove passwords from the VBA projects, you may also follow the steps below.
- Open the project properties window.
- And then click the tab “Protection”.
- Next clear all the settings in the window.
- After that, click the button “OK”. And now, you have removed the password from the project. And the next time, you can directly check the codes and properties in the editor.
Encrypt Your Essential Excel Files
There are certainly some mission-critical Excel files in your computer. You need to protect those files and keep them safe. However, even if you have encrypted your essential Excel files, you still have the chance to suffer from data disaster. Even if you use a very potent encryption method, certain hackers own the ways of decryption. To repair Excel errors, you can seek to our qualified programmer for help. With years of experience, you are sure to get a satisfactory answer.
Anna Ma is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair docx data damage and outlook repair software products. For more information visit www.datanumen.com