Microsoft Excel Cannot Run Macro – How to Fix “Microsoft Has Blocked Macros Because the Source of This File Is Untrusted”
Microsoft Excel VBA macros are widely used to automate repetitive operations such as compiling CSV files, filtering data, preparing reports, importing inform...
Microsoft Excel VBA macros are widely used to automate repetitive operations such as compiling CSV files, filtering data, preparing reports, importing information, generating invoices, performing calculations, and processing large datasets.
However, users may sometimes open a macro-enabled Excel workbook and receive an error similar to:
Cannot run the macro. The macro may not be available in this workbook or all macros may be disabled.
At the same time, Excel may display a red SECURITY RISK notification:
Microsoft has blocked macros from running because the source of this file is untrusted.
This situation is particularly common with .xlsm, .xltm, .xla, and .xlam files downloaded from the Internet, received through email or messaging applications, copied from certain network locations, or extracted from downloaded ZIP archives.
In many cases, there is absolutely nothing wrong with the VBA code itself. Windows has classified the file as originating from an untrusted security zone, and Microsoft Office is therefore preventing the VBA code from executing.
Microsoft intentionally introduced stricter macro controls because malicious Office macros have historically been used to distribute malware and ransomware.
This article explains the technical reason for the problem, how to diagnose it, safe methods of resolving it, and what to check if the macro still fails after the security restriction has been removed.
1. Typical Excel Macro Error
Suppose you have a macro-enabled workbook named:
FILTER OUT DATA 3 FIELD MAXIMUM.xlsm
The workbook contains a button such as:
Click to Compile Data
The button is assigned to a VBA procedure:
CompileCSVFilesWithCriteriaAndHeaders
When the button is clicked, Excel displays:
Cannot run the macro "'FILTER OUT DATA 3 FIELD MAXIMUM.xlsm'!CompileCSVFilesWithCriteriaAndHeaders'. The macro may not be available in this workbook or all macros may be disabled.
If a red SECURITY RISK banner is also visible at the top of Excel stating that Microsoft has blocked macros because the source is untrusted, that banner provides an important clue: Excel security is preventing the macro from executing.
2. Why Does Microsoft Excel Block Macros?
VBA stands for Visual Basic for Applications.
A VBA macro is executable code embedded inside an Office document. Because VBA can interact with files, applications and Windows resources, malicious macros can potentially be abused.
For this reason, modern versions of Microsoft Office apply additional restrictions to macro-enabled documents originating from the Internet.
Microsoft explains that Office now blocks VBA macros by default for files identified as originating from the Internet.
Common examples include files obtained from:
- Web browser downloads
- Email attachments
- Cloud downloads
- File-sharing websites
- Messaging applications
- Internet-facing servers
- Certain network shares
- ZIP files downloaded from the Internet
Therefore, even a legitimate Excel workbook developed internally may become blocked after being emailed or downloaded.
3. Understanding Mark of the Web (MOTW)
The underlying Windows mechanism is commonly known as Mark of the Web, abbreviated as MOTW.
When Windows recognizes that a file came from an Internet or restricted security zone, it can associate security-zone information with that file.
Microsoft documents that Internet-originated Office files can receive Mark of the Web and that Office uses this information when deciding whether VBA macros should be permitted to execute.
This is why two identical Excel files can behave differently:
Workbook A
C:\Company\Reports\Report.xlsm
may execute correctly.
But an identical copy downloaded from an email or website:
C:\Users\User\Downloads\Report.xlsm
may display:
SECURITY RISK
Microsoft has blocked macros from running because
the source of this file is untrusted.
The VBA code may be identical. The security metadata attached to the files is different.
4. Windows Security Zone IDs
Windows security zones can be represented using ZoneId values.
Microsoft documents these values as:
| ZoneId | Security Zone |
|---|---|
| 0 | My Computer |
| 1 | Local Intranet |
| 2 | Trusted Sites |
| 3 | Internet |
| 4 | Restricted Sites |
A file marked with:
ZoneId=3
is considered to have originated from the Internet zone.
Consequently, Office may block VBA macros in the document.
5. How to Check Whether the Excel File Is Blocked
The easiest method is through Windows File Explorer.
First close the Excel workbook.
Locate the .xlsm file in File Explorer.
Right-click the file and select:
Properties
On the General tab, look toward the bottom of the window.
You may see a Security message similar to:
This file came from another computer and might be blocked to help protect this computer.
An Unblock checkbox may appear underneath.
If it is present, Windows has identified the file as potentially originating from another computer or an untrusted security zone.
6. Solution 1 – Unblock the Individual Excel File
For a trusted workbook, this is usually the simplest solution.
Step 1
Close Excel completely.
Step 2
Find the .xlsm file.
Step 3
Right-click it and select:
Properties
Step 4
Under the General tab, locate:
Security
Step 5
Select:
Unblock
Step 6
Click:
Apply → OK
Step 7
Reopen the Excel workbook.
Now test the macro again.
Microsoft specifically documents the Properties → Unblock method as one way of removing Mark of the Web from an individual trusted file.
7. Solution 2 – Use a Trusted Location
If an organization regularly uses internally developed Excel macro files, repeatedly unblocking individual files can become inconvenient.
Excel provides Trusted Locations for this purpose.
A Trusted Location is a folder whose files are trusted by Microsoft Office. Microsoft recommends carefully controlling these locations because active content stored there can bypass normal Trust Center checking.
For example, create:
C:\Trusted Excel Macros\
Then open Excel and navigate to:
File → Options → Trust Center → Trust Center Settings
Select:
Trusted Locations
Click:
Add new location
Select:
C:\Trusted Excel Macros\
Click OK.
Move trusted macro-enabled workbooks into this directory.
For example:
C:\Trusted Excel Macros\FILTER OUT DATA 3 FIELD MAXIMUM.xlsm
Reopen the workbook and test the macro.
8. Security Warning About Trusted Locations
Trusted Locations should not be created casually.
Do not make broad directories such as the following trusted without a genuine administrative reason:
C:\
or
C:\Users\
or your entire Downloads directory.
The reason is simple: a malicious macro-enabled file copied into such a directory might receive the same trusted treatment.
Instead, create a dedicated controlled directory such as:
C:\CompanyMacros\
or:
C:\TrustedExcelApps\
Only place verified company workbooks inside it.
Microsoft specifically advises that Trusted Locations should be managed carefully and used sparingly.
9. Solution 3 – Use PowerShell Unblock-File
System administrators managing multiple files can also use PowerShell.
For example:
Unblock-File -Path "C:\Reports\Report.xlsm"
This removes the Internet zone information associated with the file.
Microsoft documents Unblock-File as another method of removing the ZoneId/Mark of the Web information.
For example:
Unblock-File -Path "C:\Trusted Excel Macros\FILTER OUT DATA 3 FIELD MAXIMUM.xlsm"
Only run this command for files whose source and contents you trust.
10. Checking the Zone.Identifier Technically
Advanced Windows administrators can inspect the security-zone information associated with a file.
For example:
notepad "C:\Reports\Report.xlsm:Zone.Identifier"
A marked file may contain information similar to:
[ZoneTransfer]
ZoneId=3
ZoneId=3 represents the Internet zone.
Microsoft documents the relationship between the Zone.Identifier, ZoneId and Mark of the Web.
11. Why “Enable Content” May Not Be Available
Users familiar with older versions of Office may expect a yellow warning bar containing:
Enable Content
However, the newer Internet-macro blocking mechanism can display a red:
SECURITY RISK
banner instead.
In this situation, the familiar Enable Content button may not be available.
That is intentional.
Microsoft changed the behavior for Internet-originated macro files so that VBA code can be blocked rather than simply presenting the traditional macro notification.
Therefore, repeatedly searching for an Enable Content button may not solve this particular problem.
12. Do Not Simply Enable All Macros
One tempting workaround is:
File → Options → Trust Center → Trust Center Settings → Macro Settings
and then selecting:
Enable VBA macros / Enable all macros
This should generally not be used as the permanent solution.
Microsoft warns users against broadly enabling macros because malicious VBA code can create a significant security risk.
A better security model is:
Unknown file → Macros blocked
Verified individual file → Unblock
Controlled internal macro application → Trusted Location
Enterprise deployment → Signed macros, trusted publishers and centrally managed policy
13. ZIP Files Can Be Important
Suppose you download:
ExcelTool.zip
and extract:
ExcelTool.xlsm
The extracted workbook may retain security characteristics associated with the downloaded archive.
Therefore, when dealing with a ZIP package from a known and trusted source, administrators may consider checking the ZIP file's Windows Properties before extraction.
If an Unblock option is available and you have verified that the archive is safe, unblock it and then extract the files.
This can be more convenient when an archive contains several trusted macro-enabled files.
14. What If the Security Banner Disappears but the Macro Still Does Not Run?
This is an important troubleshooting distinction.
Suppose you successfully remove the security restriction.
The red:
SECURITY RISK
banner disappears.
But clicking:
Click to Compile Data
still produces:
Cannot run the macro...
At this point, the problem may no longer be Windows security.
You should investigate the VBA project and button assignment.
15. Check Whether the Macro Actually Exists
Press:
Alt + F11
This opens the Visual Basic Editor.
Press:
Ctrl + F
Search for the procedure name.
For example:
CompileCSVFilesWithCriteriaAndHeaders
You should find a procedure similar to:
Sub CompileCSVFilesWithCriteriaAndHeaders()
' VBA processing code
End Sub
If the procedure does not exist, the Excel button may still be referencing an old macro that was deleted or renamed.
16. Check the Button's Macro Assignment
An Excel button or shape can be assigned to a VBA procedure.
Right-click the button.
Select:
Assign Macro
Check which macro appears.
For example:
CompileCSVFilesWithCriteriaAndHeaders
If the button references a macro from an old workbook, you may see something similar to:
'OldWorkbook.xlsm'!CompileCSVFilesWithCriteriaAndHeaders
while your current workbook is:
NewWorkbook.xlsm
In that situation, reassign the button to the correct macro.
17. Macro Name Changed
Suppose the original macro was:
Sub CompileCSVFilesWithCriteriaAndHeaders()
but a developer later renamed it:
Sub CompileCSVData()
The button may still be configured to call:
CompileCSVFilesWithCriteriaAndHeaders
Excel will therefore fail to find the expected procedure.
Reassigning the button to:
CompileCSVData
can resolve the problem.
18. Public vs Private Procedures
A macro intended to be called directly from an Excel button should normally be accessible appropriately.
For example:
Public Sub CompileCSVFilesWithCriteriaAndHeaders()
End Sub
or simply:
Sub CompileCSVFilesWithCriteriaAndHeaders()
End Sub
A procedure declared as:
Private Sub CompileCSVFilesWithCriteriaAndHeaders()
End Sub
may not be available in the same manner for normal macro assignment.
Therefore, verify the declaration if the procedure exists but does not appear in the macro list.
19. Check Where the VBA Procedure Is Stored
Normal user-executable macros are commonly placed in a standard VBA module.
In the VBA editor, look under:
VBAProject
Microsoft Excel Objects
Modules
Module1
Module2
For ordinary button-triggered procedures, storing the macro in a standard module is generally the cleanest structure.
For example:
Public Sub CompileCSVFilesWithCriteriaAndHeaders()
' Code
End Sub
20. Verify the File Extension
VBA code requires a macro-capable Excel file format.
Common formats include:
.xlsm
.xlsb
.xltm
.xlam
A standard:
.xlsx
workbook does not preserve VBA macros.
A common mistake is opening an .xlsm workbook and then saving it as:
Workbook.xlsx
Excel normally warns that VB project features cannot be saved in a macro-free workbook.
If the user proceeds anyway, the VBA project can be removed from the saved copy.
21. Excel File Format Comparison
| Extension | Description | VBA Support |
.xlsx |
Standard Excel Workbook | No |
.xlsm |
Macro-Enabled Workbook | Yes |
.xlsb |
Excel Binary Workbook | Yes |
.xltx |
Standard Excel Template | No VBA |
.xltm |
Macro-Enabled Template | Yes |
.xlam |
Excel Add-in | Yes |
Therefore, if a workbook depends on VBA automation, make sure it remains in an appropriate macro-enabled format.
22. Network Share Problems
Macro security can become more complicated when workbooks are stored on a server.
For example:
\\SERVER01\Accounts\Tools\Report.xlsm
or accessed through an IP address:
\\192.168.1.10\Accounts\Report.xlsm
Microsoft notes that files on network shares can sometimes be treated as belonging to an untrusted security zone, particularly depending on how the location is identified and configured.
In an enterprise environment, administrators should therefore properly configure trusted intranet resources instead of globally weakening Office security.
23. Local Intranet vs Trusted Sites
For centrally stored workbooks, Microsoft documents approaches involving:
- Trusted Sites
- Local Intranet zone
- Trusted Locations
- Enterprise policy
- Digital signatures and trusted publishers, depending on the scenario
Administrators should select the approach according to the organization's security architecture rather than disabling protection globally.
24. Digitally Signing VBA Macros
Organizations that distribute internally developed Excel applications should consider digitally signing their VBA projects.
A digital signature helps establish:
- Who published the VBA project
- Whether the signed code has been modified
- Whether the publisher is trusted
This is especially useful when an organization distributes the same macro applications to many employees.
Microsoft's enterprise guidance includes digitally signed macros and trusted publishers among the methods available for controlled macro deployment.
25. Recommended Enterprise Architecture
Instead of allowing users to randomly enable macros, an organization can establish:
Approved VBA Application
↓
Code Review
↓
Malware Scan
↓
Digital Signature
↓
Trusted Publisher / Controlled Location
↓
User Executes Macro
This is considerably safer than:
Every User
↓
Enable All Macros
↓
Any XLSM File Can Execute
26. Recommended Troubleshooting Sequence
When you receive:
Cannot run the macro. The macro may not be available in this workbook or all macros may be disabled.
use this sequence:
Step 1 – Look at the Excel security banner
If it says:
Microsoft has blocked macros from running because
the source of this file is untrusted.
investigate MOTW/security first.
Step 2 – Close Excel
Do not troubleshoot the file while multiple copies remain open.
Step 3 – Check Properties
Right-click the workbook:
Properties → General → Security
If available, use Unblock after verifying that the workbook is trusted.
Step 4 – Reopen Excel
Test the button again.
Step 5 – Use a Trusted Location if appropriate
For regularly used verified macro applications, use a dedicated controlled Trusted Location.
Step 6 – Check the VBA macro
Press:
Alt + F11
Search for the macro name.
Step 7 – Verify button assignment
Right-click the Excel button:
Assign Macro
Confirm that it points to the correct procedure.
Step 8 – Verify file format
Make sure the workbook remains:
.xlsm
rather than:
.xlsx
Step 9 – Check organization policies
On managed business computers, Group Policy or Microsoft 365 security policies may override local Trust Center settings.
27. Important Difference: Security Problem vs VBA Problem
This distinction can save considerable troubleshooting time.
Security Problem
Symptoms:
SECURITY RISK
Microsoft has blocked macros...
Likely areas to investigate:
- Mark of the Web
- File Properties
- Trusted Location
- Internet security zone
- Network location
- Group Policy
- Office security policy
VBA/Application Problem
Symptoms continue after security blocking has been removed.
Investigate:
- Macro deleted
- Macro renamed
- Incorrect button assignment
- Wrong workbook reference
- Private procedure
- Missing module
- Corrupted VBA project
- File converted to
.xlsx - VBA compilation error
- Missing reference or dependency
This separation is extremely useful for IT administrators.
28. Common Mistakes
Mistake 1: Reinstalling Microsoft Office immediately
A security policy issue normally does not require reinstalling Office.
Mistake 2: Rewriting working VBA code
If Excel explicitly states that macros are blocked because the file source is untrusted, investigate security before modifying code.
Mistake 3: Enabling every macro globally
This unnecessarily reduces security.
Mistake 4: Trusting the Downloads folder
The Downloads folder regularly receives Internet files and should generally not be made a broad Trusted Location.
Mistake 5: Assuming every .xlsm file is safe
.xlsm only means that the file supports macros. It says nothing about whether the embedded VBA is trustworthy.
Mistake 6: Ignoring network security zones
A perfectly legitimate workbook can behave differently when moved from a local disk to a network path.
29. Security Recommendations for IT Administrators
Organizations heavily dependent on Excel VBA should maintain formal controls.
Recommended practices include:
- Keep Office fully updated.
- Keep Microsoft Defender or another reputable endpoint-security product active.
- Never enable macros in unknown attachments.
- Scan downloaded macro-enabled files.
- Use dedicated Trusted Locations only where necessary.
- Restrict write access to Trusted Locations.
- Consider digitally signing internally developed VBA.
- Maintain backups of critical
.xlsmapplications. - Keep a separate copy of VBA source code.
- Document macro names and their functions.
- Restrict users from changing enterprise macro policies unnecessarily.
- Review macro applications when employees or external developers modify them.
- Avoid globally enabling all VBA macros.
Microsoft's guidance emphasizes that macros are active content and should only be enabled when their purpose and source are trusted.
30. Example Troubleshooting Case
Consider the workbook:
FILTER OUT DATA 3 FIELD MAXIMUM.xlsm
It contains a button:
Click to Compile Data
which calls:
CompileCSVFilesWithCriteriaAndHeaders
Excel reports:
Cannot run the macro...
and displays:
SECURITY RISK
Microsoft has blocked macros from running because
the source of this file is untrusted.
The first investigation should not be rewriting:
CompileCSVFilesWithCriteriaAndHeaders
Instead, check whether the workbook has Mark of the Web.
A practical diagnostic path is:
Close Excel
↓
Right-click XLSM
↓
Properties
↓
Check for Unblock
↓
Verify file is trustworthy
↓
Unblock
↓
Reopen Excel
↓
Test Macro
If the macro now works, VBA was not the underlying problem.
If the red security warning disappears but the macro still fails:
Alt + F11
↓
Locate VBA Procedure
↓
Verify Procedure Name
↓
Check Standard Module
↓
Return to Excel
↓
Right-click Button
↓
Assign Macro
↓
Verify Correct Procedure
This method avoids unnecessary modifications to working VBA applications.
31. Final Conclusion
The Excel message:
Microsoft has blocked macros from running because the source of this file is untrusted
is primarily a security feature rather than evidence that the Excel workbook is damaged.
Modern Microsoft Office versions treat Internet-originated VBA files more cautiously because malicious macros have historically been an important malware delivery mechanism.
For a verified and trusted workbook, the preferred approaches are generally:
For one file:
Right-click → Properties → Unblock
For controlled recurring internal files:
Excel → Trust Center → Trusted Locations
For enterprise environments:
Central security policies
+ controlled Trusted Locations
+ digitally signed VBA where appropriate
Only after the security restriction has been eliminated should you begin changing VBA code, reassigning buttons or debugging procedure names.
Most importantly, do not globally enable all macros merely to fix one trusted workbook. The goal should be to make the specific legitimate application work while preserving Microsoft's macro-security protections for unknown files.
Frequently Asked Questions (FAQ)
1. Why does Excel say “Cannot run the macro”?
Excel may display this message when macros are disabled, the workbook is untrusted, the macro no longer exists, the macro name has changed, or the button points to an incorrect procedure.
2. Why does Excel say the source of the file is untrusted?
Windows may have marked the file as originating from the Internet or another untrusted security zone. Office can use that information to block VBA execution.
3. What is Mark of the Web?
Mark of the Web, or MOTW, is Windows security metadata used to identify content originating from an Internet or restricted security zone.
4. Does this error mean my VBA code is damaged?
No. If Excel explicitly displays the red untrusted-source warning, the VBA may be completely functional but prevented from running.
5. How do I unblock a trusted .xlsm file?
Close Excel, right-click the file, select Properties, select Unblock if available, click Apply, and reopen the workbook.
6. What if the Unblock option is missing?
The file may not have MOTW, or it may be stored in a network/cloud environment where security-zone handling differs. Consider a properly controlled Trusted Location or enterprise zone configuration.
7. What is an Excel Trusted Location?
It is a folder configured in Office as trusted so that files stored there are not subjected to some normal Trust Center checks.
8. Where are Trusted Locations configured?
Navigate to:
Excel → File → Options → Trust Center → Trust Center Settings → Trusted Locations
9. Should I add my entire C: drive as a Trusted Location?
No. Use a narrowly controlled folder dedicated to trusted Office applications.
10. Should I make Downloads a Trusted Location?
Generally no. Downloads frequently contains Internet-originated files.
11. Should I select Enable All Macros?
Not as a general solution. Microsoft warns against broadly enabling macros because malicious VBA can pose a security risk.
12. Can PowerShell unblock an Excel file?
Yes. For a file you have verified as trustworthy:
Unblock-File -Path "C:\Reports\Report.xlsm"
Microsoft documents Unblock-File as a method of removing the ZoneId information.
13. Can email attachments cause this problem?
Yes. Macro-enabled Office files obtained through Internet-related sources such as email attachments can receive Mark of the Web.
14. Can downloading an .xlsm file from a website cause it?
Yes. This is one of the main scenarios addressed by Microsoft's macro-blocking security behavior.
15. Can ZIP files be involved?
Yes. Files extracted from Internet-downloaded archives can be affected by Internet-origin security marking.
16. Can network shares cause macro blocking?
Yes. Depending on how the share is accessed and classified, Office may consider it outside the trusted/local intranet zone.
17. Why does a workbook work on one computer but not another?
The machines may have different Trust Center settings, Windows zone information, Group Policies, Trusted Locations, security software, or Office configurations.
18. Why does a local copy work but the server copy fails?
The network path may be classified differently from the local directory.
19. Can Group Policy override my Excel settings?
Yes. Enterprise Office policies can control macro behavior independently of what an individual user attempts to configure.
20. How can I check whether the macro actually exists?
Press Alt + F11 and search the VBA project for the procedure name.
21. How can I check which macro a button runs?
Right-click the button or shape and select Assign Macro.
22. What if the macro name has changed?
Reassign the button to the new procedure or restore the original procedure name.
23. Can .xlsx contain VBA macros?
No. Use a macro-capable format such as .xlsm when VBA must be retained.
24. What happens if I save an .xlsm as .xlsx?
VBA features cannot be retained in the normal .xlsx format. Excel normally warns you before saving.
25. Is .xlsm itself dangerous?
No. It simply indicates that the workbook is capable of containing VBA macros. The actual risk depends on the code and its source.
26. Is every digitally signed macro safe?
No security mechanism should replace source verification and appropriate security review. A signature helps establish publisher identity and code integrity, but administrators must still decide whether that publisher should be trusted.
27. Should companies digitally sign their VBA applications?
It can be an appropriate security and management strategy for organizations distributing internally developed macro applications to multiple users.
28. Can antivirus software detect malicious macros?
Modern endpoint security can detect many known threats, but macro security controls should still remain enabled. Microsoft recommends maintaining protection against macro-based attacks.
29. Should I disable Microsoft Defender to make the macro work?
No. Disabling endpoint protection is not an appropriate general solution for a macro trust problem.
30. Do I need to reinstall Excel?
Usually not. First determine whether the issue is MOTW, Trust Center configuration, enterprise policy, macro availability, or button assignment.
#MicrosoftExcel #Excel #ExcelMacros #VBA #ExcelVBA #Microsoft365 #Office365 #ExcelTips #ExcelHelp #ExcelError #MacroError #MacroSecurity #ExcelSecurity #SecurityRisk #MicrosoftOffice #Windows11 #Windows10 #XLSM #VBAMacros #ExcelAutomation #ExcelTroubleshooting #MicrosoftSupport #TechSupport #ITSupport #WindowsSupport #ExcelSolutions #TrustCenter #TrustedLocation #MarkOfTheWeb #MOTW #PowerShell #UnblockFile #CyberSecurity #OfficeSecurity #MacroMalware #DataSecurity #ITSecurity #ExcelWorkbook #ExcelDeveloper #VBADeveloper #ExcelProgramming #MacroEnabled #WindowsSecurity #TechnicalSupport #SystemAdministrator #ITAdministrator #ExcelFix #OfficeTroubleshooting #TechKnowledge #KnowledgeBase
Was this guide useful?
Your answer helps us keep BISONKB accurate and practical.