Excel Macro Security (2 Necessary Aspects)

Get FREE Advanced Excel Exercises with Solutions!

Macros can cause serious damage to your computer. It happens to erase files or install malware. Thus, users need to know about Excel macro security. In addition to that, Microsoft has already added macro-security features to help prevent your working devices (computers or smartphones) from macro-related problems.

Excel Macro Security

Go through the below sections to learn essential things about Excel macro security. This article is part of my series: Excel VBA & Macros – A Step by Step Complete Guide.

Download Practice Workbook

This file contains a VBA Macro. When you open it, it will show a Security Warning.

What Are Macro Viruses?

When you access workbooks, Excel VBA macros can operate on most Windows systems and perform various activities. This could create a risk because it might enable the presence of hidden viruses in Excel files that can be activated upon opening a workbook.

Users can tell which macros are trustworthy and which are not thanks to the various macro security features provided by Microsoft. By setting macro security levels, users can manage macro execution and choose which macros are permitted to run.

What Is Macro Enabled Excel Workbook?

The workbooks containing a file extension of .xlsx can not store any macro. Any Excel files are saved as xlsx files by default and are trustworthy workbooks.

However, you must be careful using a file with .xlsm files as they can store macros. These workbooks are known as Macro Enabled Excel Workbooks. Check the origin of this type of file before opening it to make sure the macros present in that workbook are not malicious.

Excel Macro Security: 2 Necessary Changes

As Excel Macros pose serious security concerns, you need to maintain certain codes of conduct while dealing with macros. We will discuss the basic security measures below.

1. Changing Macro Security Settings

There are four different macro security settings present in Excel to change your security system according to your need. To open the Macro Setting in the Trust Center, follow the steps below.

  • Go to the Developer tab >> click on Macro Security under Code group.

Opening Trust Center Box

Now, you will find four different Macro Settings options.

  • Disable VBA macros without notification: this will disable any macro present in an Excel file but will not show any notification. You will not be able to run any code except the ones saved in trusted locations.
  • Disable VBA macros with notification: this option will disable all the macros present in the file with a security alert. This is the default option. You can enable macros on a case-by-case basis.
  • Disable VBA macros except digitally signed macros: if there are unsigned macros in the file, it will disable them with a security alert. However, if the macros are digitally signed by trusted publishers they will run. For unsigned macros, you will receive a warning to enable the signed macro and trust the publisher.
  • Enable VBA macros (not recommended; potentially dangerous code can run): it will enable all the macros to run. It may cause potential malicious code to run too.

You also have an additional settings option with a checkbox.

  • Trust access to the VBA project object model: This option enables automation clients to programmatically access the Visual Basic for Applications (VBA) object model, allowing code to automate Office applications and modify the VBA environment and object model.

Different types of Macro Settings

Note: If you change these settings, it will only be applicable for Excel Files, not other Microsoft Office programs.

Read More: 22 Macro Examples in Excel VBA

2. Assigning Specific Folders as Trusted Locations

You may prefer to designate one or more folders as Trusted Locations, rather than deal with individual workbooks. You can open all the workbooks in a trusted location without a macro warning.

  • You can designate a folder as trusted by moving File >> Options >> Trust Center >> Trust Center Settings >> Trusted Locations >> Add New Location.

Adding New Location

  • Microsoft Office Trusted Location window opens up. Click on Browse.

Browse to add new location

  • Assign the desired location and tick the Subfolders of this location are also trusted then click OK.

Assigning Location

Read More: VBA Macro to Delete Row if Cell Contains Value in Excel (2 Methods)

What to Do If Microsoft Has Blocked Macros from Running?

When you open an Excel file with macro it may block macros from running and show a security message like the image shown below. If you click on Learn More, it will not enable the macros, instead, it will take you to a web page explaining it.

error message when Microsoft Has Blocked Macros from Running

To unblock code from this type of file follow the steps given below.

  • Close your workbook containing this type of security message.
  • Then, again select your file and Right-click on it >> select Properties.

Selecting and right-clicking on Excel File

  • In the Properties dialog box, check the Unblock option >> click on OK.

clicking Unblock option

  • Now, if you open your workbook, you will be able to run the macros of that file.

Read More: How to Edit Macros in Excel (2 Methods)

How to Enable/Disable Security Alerts on Message Bar

You can enable or disable security alerts on the message bar in Excel by following the steps given below.

  •  Click on the File tab >> Options >> Trust Center >> Trust Center Settings >> Message Bar.
  • Now, you will get Message Bar Settings for all Office Applications.
  • Here, you will get two options. The first option is the default. It will show a message bar when potentially unsafe contents such as ActiveX controls or macros have been disabled.

Showing Message Bar

  • However, if you have already selected the Disable VBA macros without notification option as Macros Setting and have not selected this option, no message bar will appear.

Disable all macros without notification in Macro Setting

  • If you select the second option, you will not get any security message from the Trust Center.

Never show information about blocked content option selection

How to Enable Macros for Individual Excel Workbooks Turning on Macros in Backstage View

You can turn on macros in backstage view for a specific workbook by following the steps given below.

  • Go to the File tab >> click on Info >> click on Enable Content >> select Enable Content.

Turning on Macros in Backstage view

Clearing All Trusted Documents

To avoid enabling macros every time you open the same file, you may save the file as a trusted document. Once you save your macro as a trusted document it will not run the macros every time you open the file without any security message.

However, if you want to clear all trusted documents you can do that by following the steps given below.

  • Go to the File tab >> click on Options >> click on Trust Center >> go to the Trusted Documents tab.
  • Then, click on the Clear button and click OK.

Clearing All Trusted Documents

How to Enable Macros for One Session

Suppose you want to run a macro for a single time and do not want that file to be a trusted one. In that case, Excel has the option to enable macros for only one session.

  • Go to the File tab >> click on Info >> click on Enable Content >> select Advanced Options.

Selecting Advanced Option

  • After that, select Enable content for this session option and click on OK.

Enable Macros for One Session

How to Protect Computer from Macro Viruses

There are a few things you should keep in mind to protect your computer from macro viruses.

  • Avoid Implicit Trust: if you are not sure about the origin or publisher of an Excel file with macros, there are possibilities of having malicious code them. Try to handle them with care before running those macros.
  • Do Not Enable Questionable Content: the best way to protect your computer from macro viruses is not to enable macros if you are not sure about if it is safe or not. All Excel versions after Excel 2016 enable you to use the data from the workbook without enabling the macros.


We hope this article sheds enough light on the fundamental issues regarding Excel macro security. Comment if you seek further clarification or have anything to add. Do check out our awesome website, Exceldemy, to find interesting articles on Excel.

Related Articles

Kawser Ahmed
Kawser Ahmed

Hello! Welcome to my Excel blog! It took me some time to be a fan of Excel. But now I am a die-hard fan of MS Excel. I learn new ways of doing things with Excel and share them here. Not only a how-to guide on Excel, but you will get also topics on Finance, Statistics, Data Analysis, and BI. Stay tuned! You can check out my courses at Udemy: udemy.com/user/exceldemy/

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF