Skip to main content

Macro security

This article contains information about the risks involved when using macros, and you can learn how to enable or disable macros in Excel.

Enable Content

If you open a workbook containing a macro, you will see a yellow bar message SECURITY WARNING Macros have been disabled at the bottom of the ribbon.

Disable Macros

If you click X to close this message, you can't run macros of this workbook. If you run a macro of this workbook, Excel will display another warning message:

Because of your security settings, macros have been disabled. To run macros, you need to reopen this workbook, and then choose to enable macros. For more information about enabling macros, click Help.

Enable Macros

If you click Enable Content, it will automatically become a trusted document. This means that as soon as you open the file on your computer, you will no longer be prompted to enable the content. The basic idea is that if you tell Excel that you "trust" a particular workbook by enabling macros, then you will probably enable macros every time you open it. As a result, Excel remembers that you have previously enabled macros and disables any further messages about macros for that workbook.

Macro Security Settings

On the Developer tab, click the Macro Security button in the Code group to launch the “Trust Center” dialog box.

In the Trust Center dialog, select the Macro Setting item in the left-hand panel.

Disable VBA Macros Without Notification

This setting prevents all macros and security alerts about macros from running. This setting is roughly equivalent to the old Very High security setting in Excel 2003. With this setting, only macros in the Trusted Locations folders can run.

Disable VBA Macros With Notification

This means that you see a notification when you open a file with macros, and you can choose to enable the content. If you ignore the notification, the macros remain disabled. This setting is similar to the Medium security setting in Excel 2003 and is the recommended setting.

Disable VBA 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.

Enable VBA Macros (Not Recommended: Potentially Dangerous Code Can Run)

All macros run without confirmation. This setting is similar to the Low macro security setting in Excel 2003. Although it requires the least amount of hassle, it also opens your computer to attacks from malicious Melissa-like viruses. Microsoft suggests that you not use this setting.

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 an Office 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.

Trusted Locations

If you don't want any macro warning messages to upset you, you can set a trusted location for your macro files. A trusted location is a directory that is considered a secure area and holds only trusted workbooks. A trusted location allows you to run a macro-enabled workbook without security restrictions, as long as the workbook is located in that location.

To set up a trusted location, do the following steps.

  1. On the Developer tab, click the Macro Security button in the Code group to launch the “Trust Center” dialog box.
  2. In the Trust Center dialog, select the Trusted Locations item in the left-hand panel.
  3. Now, click the Add new location button to open the “Microsoft Office Trusted Location” dialog.
  4. Click Browse to find and specify the directory that will be considered a trusted location.
  5. Click the OK button to see your selected folder added to the list of Trusted Locations in the Trust Center.

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>