Sign in with Microsoft
Sign in or create an account.
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

A macro is a series of commands used to automate a repeated task and can be run when you have to perform the task. Macros can automate frequently used tasks to save time on keystrokes and mouse actions.

However, some macros can pose a security risk. Macros are often used by people with malicious intent to quietly install malware, such as a virus, on your computer or into your organization's network.

Warning: Never enable macros in a Microsoft 365 file unless you're sure what those macros do. Unexpected macros can pose a significant security risk. You don't have to enable macros to see or edit the file; only if you want the functionality provided by the macro. For more information see Protect yourself from macro viruses.

Change macro settings in the Trust Center

Macro settings are located in the Trust Center. However, if your device is managed by your work or school the system administrator might prevent anyone from changing settings.

Important: When you change your macro settings in the Trust Center, they are changed only for the Microsoft 365 program that you are currently using. The macro settings are not changed for all your Microsoft 365 programs.

  1. Click the File tab.

  2. Click Options.

  3. Click Trust Center, and then click Trust Center Settings.

  4. In the Trust Center, click Macro Settings.

    macro settings area of trust center

  5. Make the selections that you want, then click OK.

Note: The options are slightly different in Excel, we'll call those out as we go.

  • Disable all macros without notification     Macros and security alerts about macros are disabled.

    In Excel this option is Disable VBA macros without notification and it only applies to VBA macros.

  • Disable all macros with notification     Macros are disabled, but security alerts appear if there are macros present. Enable macros on a case-by-case basis.

    In Excel this option is Disable VBA macros with notification and it only applies to VBA macros.

  • Disable all macros except digitally signed macros     Macros are disabled, and security alerts appear if there are unsigned macros present. However, if the macro is digitally signed by a trusted publisher, the macro just runs. If the macro is signed by a publisher you haven't trusted yet, you are given the opportunity to enable the signed macro and trust the publisher.

    In Excel this option is Disable VBA macros except digitally signed macros and it only applies to VBA macros.

  • Enable all macros (not recommended, potentially dangerous code can run)     All macros run without confirmation. This setting makes your computer vulnerable to malicious code.

    In Excel this option is Enable VBA macros (not recommended, potentially dangerous code can run) and it only applies to VBA macros.

  • Excel also has a checkbox for Enable Excel 4.0 macros when VBA macros are enabled. If you select this checkbox all of the above settings for VBA macros will also apply to Excel 4.0 (XLM) macros.

    If this checkbox is not selected XLM macros are disabled without notification.

  • Trust access to the VBA project object model     Disallow or allow programmatic access to the Visual Basic for Applications (VBA) object model from an automation client. This security option is for code written to automate a Microsoft 365 program and manipulate the VBA environment and object model. It is a per-user and per-application setting, and denies access by default, hindering unauthorized programs from building harmful self-replicating code. For automation clients to access the VBA object model, the user running the code must grant access. To turn on access, select the check box.

    Note: Microsoft Publisher and Microsoft Access have no Trust access to the VBA project model object option.

For info on creating macros please see Quick start: Create a macro.

For info on using macros on a machine running Windows S see Block suspicious macros in Office on Windows 10 S.

See Also

Change macro security settings in Excel

How malware can infect your PC

Need more help?

Expand your skills


Get new features first


Was this information helpful?

What affected your experience?

Thank you for your feedback!