Home >Common Problem >How to enable or disable macros in Excel

How to enable or disable macros in Excel

王林
王林forward
2023-04-13 22:43:046616browse

What is a macro?

A macro is a set of instructions that instruct Excel to perform an operation or sequence of operations. They save you from performing repetitive tasks in Excel.

In its simplest form, you can record a series of actions in Excel and save them as macros. Then, running your macro will perform the same sequence of operations as many times as you need. For example, you may want to insert multiple worksheets into your document. Inserting one at a time is not ideal, but a macro can insert any number of worksheets by repeating the same steps over and over.

You can make macros more powerful by writing your own macros using the Visual Basic (VBA) programming language rather than just recording them. This allows you to create highly complex macros that do almost anything you want.

Why should you disable macros in Excel?

Macros can make your life easier, but there are risks when using them. That's because when you open a file created by someone else that contains macros, you don't know what those macros are. Macros can be inserted into Excel documents, which can cause serious damage to your computer. These malicious macros can spread viruses and other forms of malware, with serious consequences.

Therefore, macros are disabled by default in Excel. When you open a document that contains macros, you'll be asked to confirm whether you want to enable macros. You should only do this if you trust the document.

You should be careful even if it is sent to you from someone you know. Many macro viruses access your contact list and send emails from your account, allowing the virus to spread.

How to Enable Macros in Excel

Enabling macros in a document is quick and easy if you're sure the document containing the macros is safe. Excel works slightly differently on Windows and Mac, so the exact steps depend on which operating system you're using.

How to enable macros in Excel on Windows

When you open an Excel file that contains macros on Windows, by default you will receive a notification that the file contains macros , with the option to enable or disable them. You can also choose to permanently enable macros for any file you open.

To enable macros in Excel on Windows:

  1. Open the Excel file that contains macros - you will see a warning above the formula bar.
  2. To enable macros, click Enable Content.
    How to enable or disable macros in Excel
  3. If you don't click this button, you can continue to use the spreadsheet normally, but you won't be able to run any macros.

If you find yourself clicking this button every time you use Excel, you can change the default settings to automatically enable macros for all Excel files. You should only do this if you are sure that the file you want to open is safe.

To permanently enable macros in Excel on Windows:

  1. Open any Excel file.
  2. Click File.
    How to enable or disable macros in Excel
  3. Select the option at the bottom of the menu.
    How to enable or disable macros in Excel
  4. Click the Trust Center menu.
    How to enable or disable macros in Excel
  5. Click the Trust Center Settings button.
    How to enable or disable macros in Excel-settings-640x266-1
  6. Select the Macro Settings menu.
    How to enable or disable macros in Excel
  7. Click the Enable VBA Macros radio button.
    How to enable or disable macros in Excel
  8. Click OK.
  9. Close your document. From now on, macros will be automatically enabled when you open any Excel document.

How to enable macros in Excel for Mac

If you use Excel for Mac, you can enable macros directly from the document you are opening. You can also choose to always enable macros for every file you open.

To enable macros in Excel for Mac:

  1. Double-click the file you want to open as usual. You will see a popup warning you that the file contains macros.
  2. Click Enable Macros to open a macro-enabled file.
    How to enable or disable macros in Excel
  3. If you do not trust the document, click Disable Macros and the file will open but all macros will be disabled.
    How to enable or disable macros in Excel
  4. You can now use your Excel file as usual.

If you disable macros when opening a document, you cannot enable macros for the document without closing the file and opening it again. However, you can change the default settings so that macros are always enabled when opening any Excel file.

However, you should only do this if you are sure that the file is safe to open.

To permanently enable macros in Excel for Mac:

  1. Open any Excel file.
  2. Click Excel in the menu bar.
    How to enable or disable macros in Excel
  3. Select Preferences.
    How to enable or disable macros in Excel
  4. Click the Security icon.
    How to enable or disable macros in Excel
  5. Select Enable all macros.
    How to enable or disable macros in Excel
  6. If the file you originally opened contains macros, you will need to close it and open it again for the new settings to take effect.

How to disable macros in Excel

If you are concerned about the risk of malicious macros, you can choose to disable macros by default.

There are two options. The first is to disable macros by default but keep notifications that the file contains macros that will appear when the file is opened. You can then decide whether to enable macros for the file.

The second option is to disable macros by default and remove notifications. This is useful if you don't want to enable macros, as it means you won't see the same pop-up notification every time you open a file that contains macros.

How to disable macros in Excel on Windows

The method to disable macros is slightly different depending on your operating system.

To disable macros in Excel on Windows:

  1. Open any Excel document.
  2. Click File.
    How to enable or disable macros in Excel
  3. At the bottom of the menu, select options.
    How to enable or disable macros in Excel
  4. Select the Trust Center menu.
    How to enable or disable macros in Excel
  5. Click Trust Center Settings.
    How to enable or disable macros in Excel-settings-640x266-1
  6. Select Macro Settings.
    How to enable or disable macros in Excel
  7. If you wish to disable macros but still enable them via the message above the formula bar, click the "Disable VBA macros and notify" radio button.
    How to enable or disable macros in Excel
  8. If you wish to disable macros and do not want to see notifications, click the Disable VBA macros without notifications radio button.
    How to enable or disable macros in Excel
  9. You can also choose to enable only digitally signed macros.
    How to enable or disable macros in Excel
  10. Click OK to save your settings. You may need to close and reopen the file for the new settings to take effect.

How to Disable Macros in Excel on Mac

If you use Excel for Mac, you need to do something different.

To disable macros in Excel for Mac:

  1. Open any Excel file.
  2. Click the Excel menu in the menu bar.
    How to enable or disable macros in Excel
  3. Select Preferences.
    How to enable or disable macros in Excel
  4. Click the Security icon.
    How to enable or disable macros in Excel
  5. To disable macros but keep notifications, select Disable All Macros With Notification.
    How to enable or disable macros in Excel
  6. To disable macros and stop notifications, select Disable All Macros without Notification.
    How to enable or disable macros in Excel
  7. You need to close and reopen the current file for new changes to take effect on the file.

The above is the detailed content of How to enable or disable macros in Excel. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yundongfang.com. If there is any infringement, please contact admin@php.cn delete