Home > Article > Software Tutorial > 3 ways to set and cancel Excel "Open Password"
How to protect your Excel files: Three ways to set an opening password In daily work, Excel files often contain sensitive data, and it is very important to prevent information leakage. Setting an opening password is one of the effective ways to protect Excel files. This article will introduce three methods of setting a password to open Excel, including using the password protection function, protecting worksheets, and protecting structures. In addition, you will also be guided on how to cancel these passwords, allowing you to flexibly control the access rights to Excel files. PHP editor Strawberry will introduce these methods in detail in the article to help you protect your data security.
Let’s first take a look at 3 ways to set a password for opening Excel.
Method 1: Set the opening password through Excel’s built-in function
1. Open the Excel sheet, click the "File" tab in the upper left corner, enter the file menu, and click "Information" → "Protect Workbook" → "Encrypt with Password".
2. When the "Encrypt Document" dialog box pops up, enter the password you want to set in the password field, and then click "OK". The system will ask you to enter the password again for confirmation.
After completing the above operations and saving the file, the password will be set when Excel is opened. The next time you open this file, you will need to enter the password to view the contents.
Method 2: Set the opening password through the "Save As" function
1. Open the Excel file that needs to be protected, click the "File" tab in the upper left corner, and then select "Save As"; after the "Save As" dialog box pops up, click the "Tools" button in the lower right corner, and then select "General Options" ".
2. When the dialog box pops up, enter the password you want to set in the "Open Permission Password" column, and then click "OK" to save the file. The password will be set when Excel opens.
Method 3: Use VBA macro code to set the opening password
1. After opening Excel, press the shortcut key "Alt + F11" to open the VBA editor. In the VBA editor, click the "Insert" menu and select "Module".
2. In the new module, enter the following code:
Sub SetPassword() Dim pw As String pw = InputBox("Please enter the password to be set") If pw "" Then ThisWorkbook.Password = pw ThisWorkbook.Save MsgBox "The password has been set successfully!" Else MsgBox "No password has been set ” End IfEnd Sub
3. Close the VBA editor, return to Excel, press "Alt + F8" to open the macro dialog box, select "SetPassword", and then click "Run". After the dialog box pops up, enter the password as prompted, and the password for opening Excel is set.
Let’s take a look at how to cancel the Excel opening password.
If you don’t want to have to do the "enter password" step every time you open Excel, so you want to cancel the password, you can cancel it according to the following method. No matter which method you originally used to set it, you can use this method.
After opening Excel with a password, follow the steps set by "Method 1" and click "File" → "Information" → "Protect Workbook" → "Encrypt with Password". After the password bar pops up, delete the existing password and leave Empty, and then click "OK", Excel will open the password and cancel it.
If you forget the password to open Excel and want to cancel the password, you will not be able to operate in Excel. In this case, we need the help of other tools.
For example, PepsiNiu Excel Password Recovery Tool, although it cannot cancel the forgotten password, it can help us retrieve the Excel password.
Select the [Retrieve Password] module in the tool, and then follow the prompts.
The above is the detailed content of 3 ways to set and cancel Excel "Open Password". For more information, please follow other related articles on the PHP Chinese website!