In Excel, when you add a password to a workbook document, you need to set the options one by one to make it more cumbersome. Below, we use a macro that runs automatically, allowing the software to automatically add a password to the document.
1, start Excel, execute the "tools → macros →visual Basic Editor" command, into the VBA edit state (Figure 1).
Enter VBA Edit state
2, in the Project Explorer window on the left, select VBAProject (PERSONAL. XLS) "(Personal Macro Workbook) option.
3, the implementation of the "Insert → module" command, insert a module (Module 1).
4. Enter the following code into the Code editing window on the right:
Sub Auto_close()
ActiveWorkbook.Password = "123456"
ActiveWorkbook.Save
End Sub
Exits the VBA edit state.
Note: This is a macro that runs automatically when you exit Excel, and its macro name (Auto_Close) cannot be modified.
5. Later, when you exit Excel, the software automatically adds a password to the current workbook (123456, which can be modified as needed) and saves the document.