Use macros to automatically add passwords to Excel workbook documents

Source: Internet
Author: User
Tags exit

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.