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.

Enable Editing

If you open a workbook download from internet, you will see a yellow bar message:

PROTECTED VIEW Be careful files from the Internet can contain viruses. Unless you need to edit it's safer to stay in Protected View.

at the bottom of the ribbon.

If you’re sure the file is safe and want to edit it, please chick Enable Editing.

Unblock Macros

If you open a macro-enabled workbook download from internet, you will see a red bar message:

SECURITY RISK Microsoft has blocked macros from running because the source of this file is untrusted.

If you’re sure the file is safe and want to unblock macros, there are a few different ways to do it, depending on your situation.

Unblock a single file

In most cases you can unblock macros by modifying the properties of the file as follows:

  1. Open Windows File Explorer and go to the folder where you saved the file.
  2. Right-click the file and choose Properties from the context menu.
  3. At the bottom of the General tab, select the Unblock checkbox and select OK.

Unblock all files from a specific network share or website

If you often download files or directly open files from a trusted cloud location, such as your company’s website or an internal file server, you can set the site as a trusted site in Windows so macros from the site won’t be checked.

  1. Tap the start button or Windows key and select Settings.
  2. In Settings window, type Internet Options.
  3. Select Internet Options from the search results and the Internet Properties dialog box will appear.
  4. On the Security tab, select Trusted Sites, then select Sites.
  5. Type the URL of the site or server that contains the Excel files with the macros you want to run (E.g. type excelbaby.com), and then select Add.

  6. Select Close and then OK.

Trusted publisher

If you're comfortable that the source of the macros is a person or company that you know you can add them as a trusted publisher to unblock this macro and any future macros the publisher signs with the same certificate.

First, you'll need to unblock this particular file using the steps above, Then, you can add the publisher as a trusted publisher so that future macros will run seamlessly.

  1. Open the file from the new publisher.
  2. Select the File tab.
  3. In the Security Warning area, click Enable Content > Advanced Options.
  4. In Microsoft Office Security Options, click Trust all documents from this publisher.

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.

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.

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>