Fix Excel Macros Have Been Disabled Error β€” VBA Macro Security Blocked

beginnerπŸ“Š Microsoft Excel2026-03-21| Microsoft Excel 2016/2019/2021/Microsoft 365 on Windows 10/11

Error Message

Macros have been disabled. Macros might contain viruses or other security hazards.
#excel#macro#security#vba

What's happening

You open an Excel file and the yellow warning bar appears immediately β€” or worse, nothing happens when you run a macro and you spot this dialog lurking:

Macros have been disabled. Macros might contain viruses or other security hazards.

The file came from a network share, an email attachment, or a browser download. Excel flagged it as potentially unsafe and killed all VBA execution without a word. Your automation goes nowhere.

Why this happens

Excel stamps files downloaded from the internet or received via email with a Mark of the Web (MOTW) β€” an invisible NTFS stream that survives unzipping and copying. Once that stamp is present, the Trust Center steps in and either disables macros entirely or demands your confirmation. Files you create locally, or that live on a mapped drive you already trust, typically skip this check.

Three things can cause this, and they're not mutually exclusive:

  • The file carries MOTW and your macro setting is "disable without notification"
  • The file's folder isn't in a Trusted Location
  • Group Policy (GPO) is enforcing macro restrictions company-wide β€” overriding everything else

Debug: figure out what's actually blocking you

Step 1 β€” Check the Trust Center setting

Open File β†’ Options β†’ Trust Center β†’ Trust Center Settings β†’ Macro Settings. Four choices appear:

  • Disable all macros without notification ← this is the silent killer
  • Disable all macros with notification ← shows the yellow bar
  • Disable all macros except digitally signed macros
  • Enable all macros (not recommended)

If it's set to the first option, you won't see any warning at all β€” macros simply don't fire.

Step 2 β€” Check if the file is blocked at the OS level

Right-click the .xlsm or .xlsb file β†’ Properties. See an Unblock checkbox at the bottom? That file has MOTW. This is your actual problem β€” changing Trust Center settings alone won't help, because the block lives at the file level, not in Excel.

Step 3 β€” Check for Group Policy enforcement

Trust Center settings greyed out? GPO is overriding them. Run this in PowerShell to confirm:

Get-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Office\16.0\Excel\Security" -Name "VBAWarnings" -ErrorAction SilentlyContinue

A value of 4 means macros are disabled by policy. Value 2 means notification only. If the key doesn't exist, GPO isn't the culprit. For a GPO-blocked machine, skip ahead to Fix 5.

Solutions

Fix 1 β€” Unblock the file (fastest fix for one-off files)

Right-click the file β†’ Properties β†’ tick Unblock β†’ Apply β†’ OK. Reopen the file. The yellow bar shows up, you click "Enable Content", and this time it sticks.

Dealing with a whole folder of files? PowerShell handles it in one shot:

# Unblock a single file
Unblock-File -Path "C:\reports\monthly_report.xlsm"

# Unblock all xlsm files in a folder
Get-ChildItem -Path "C:\reports" -Filter "*.xlsm" -Recurse | Unblock-File

Fix 2 β€” Add a Trusted Location (best for recurring files)

Running macros from the same folder every week? Make that folder a Trusted Location and stop fighting the security prompt forever:

  • File β†’ Options β†’ Trust Center β†’ Trust Center Settings
  • Trusted Locations β†’ Add new location
  • Browse to your folder; tick Subfolders of this location are also trusted if needed
  • Click OK

Files inside Trusted Locations bypass all macro security checks. Create a dedicated folder β€” something like C:\MacroFiles\ β€” and keep your production macro workbooks there. Clean, predictable, no surprises.

Fix 3 β€” Adjust macro security level (if you control the machine)

Head to File β†’ Options β†’ Trust Center β†’ Trust Center Settings β†’ Macro Settings and pick Disable all macros with notification. Macros stay blocked by default, but you get the yellow bar and the choice to enable per file. It's the safest non-blocking setting Excel offers.

Fix 4 β€” Sign the VBA project (for distributed files)

Shipping macro-enabled workbooks to colleagues or clients? A code-signing certificate lets recipients run your macros under the "digitally signed only" policy without touching their security settings. To generate a self-signed cert for internal use:

' Run in elevated PowerShell to create the certificate:
New-SelfSignedCertificate -Type CodeSigningCert -Subject "CN=ExcelMacros" -CertStoreLocation Cert:\CurrentUser\My

Then inside Excel: open the VBA editor (Alt+F11) β†’ Tools β†’ Digital Signature β†’ select your cert β†’ sign the project β†’ save as .xlsm. Recipients need to trust your cert once β€” after that, the file runs cleanly.

Fix 5 β€” GPO blocked you (escalation path)

Policy-enforced restrictions leave you two realistic options without admin privileges:

  • A Trusted Location on a network share β€” GPO frequently still honors this even when it blocks internet macros. Ask IT to whitelist a specific UNC path like \\fileserver\macros\.
  • Office Scripts β€” if you're on Microsoft 365, these run in the browser, skip VBA entirely, and carry zero macro security restrictions. Migration takes effort, but it's the permanent fix.

Verify the fix worked

Drop this into a new module and hit Run:

Sub TestMacroEnabled()
    MsgBox "Macros are running! Security fix confirmed.", vbInformation
End Sub

Message box appears? Done. Nothing happens? Open the Immediate Window (Ctrl+G in the VBA editor) and look for errors β€” sometimes a macro fires but crashes on a specific operation, which is a separate problem from security blocking.

Also confirm your Trusted Location survived: File β†’ Options β†’ Trust Center β†’ Trust Center Settings β†’ Trusted Locations. Your path should be listed.

Lessons learned

The trap most people fall into: they fix the Trust Center setting, reopen the file, macros still don't run, assume the setting didn't save, and loop back into the same menu three times. The real culprit is the file-level MOTW block. Check the Properties unblock checkbox before touching anything else β€” it takes five seconds and rules out half the possibilities.

Build the habit now: any macro file that arrives via email or download gets right-clicked β†’ Unblocked before it's ever opened. Two seconds up front versus fifteen minutes of debugging later.

Running macro-heavy workbooks for a whole team? Spend an hour setting up a Trusted Location on a shared network drive and write it up in your team wiki. That one-time investment eliminates this exact problem β€” including the 2 AM version.

Related Error Notes