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.
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.
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.
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.
- Microsoft Office Trusted Location window opens up. Click on Browse.
- Assign the desired location and tick the Subfolders of this location are also trusted then click OK.
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.
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.
- In the Properties dialog box, check the Unblock option >> click on OK.
- 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.
- 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.
- If you select the second option, you will not get any security message from the Trust Center.
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.
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.
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.
- After that, select Enable content for this session option and click on OK.
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.