Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Block Win32 API Calls from Office Macros: Step-by-Step

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

You can block Win32 API calls from Office macros by enabling the relevant Group Policy or registry setting that stops VBA from loading external DLL functions. This closes a common malware path: attackers use VBA to call functions like CreateProcess or URLDownloadToFile to launch programs or download payloads. The setting is available in Windows builds that include the Attack Surface Reduction (ASR) rules and in Microsoft 365 Apps for enterprise; it is not available in every Office edition, so check your version first.

What You'll Need

  • Windows 10 or Windows 11 (the ASR rule described here is not available on older Windows versions).
  • Microsoft 365 Apps for enterprise or a Windows edition that supports Group Policy (Pro, Enterprise, Education). Home editions lack the Group Policy Editor but can use the registry method.
  • Administrator rights on the device.
  • Optional: Microsoft Endpoint Manager (Intune) if you manage many devices centrally.

Step-by-Step

  1. Confirm your Office and Windows versions. Open Word, go to File > Account and check the product name. Then open Settings > System > About and note the Windows edition. The ASR rule below requires Windows 10 or 11 and a supported Office build. If you are on Office 2016 or 2019 volume editions, the rule may not apply; skip to the registry method or check Microsoft's documentation for your build.
  2. Open the Local Group Policy Editor. Press Win+R, type gpedit.msc and press Enter. On Home editions this tool is not included; use the registry method in step 6 instead. Menu labels can differ slightly by Windows version and region.
  3. Navigate to the ASR rules. Go to Computer Configuration > Administrative Templates > Windows Components > Microsoft Defender Antivirus > Microsoft Defender Exploit Guard > Attack Surface Reduction. If you do not see this path, your Windows build may not include the ASR templates; update Windows or use Intune.
  4. Enable the rule for Office macro Win32 API calls. Double-click Configure Attack Surface Reduction rules, select Enabled, then click Show. Add an entry with the name 92E97FA1-2EDF-4476-BDD6-9DD0B4DDDC7B and a value of 1 (Block) or 2 (Audit). Use Audit first if you want to see what would be blocked without breaking workflows.
  5. Apply and restart Office. Click OK through the dialogs, then close and reopen Word, Excel and PowerPoint. The rule takes effect for new macro sessions; existing sessions may need a full sign-out or reboot.
  6. Registry alternative (Home editions or scripted deployment). Open Registry Editor as administrator and go to HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Windows Defender Exploit Guard\ASR\Rules. Create a String value named 92E97FA1-2EDF-4476-BDD6-9DD0B4DDDC7B and set its data to 1 for Block or 2 for Audit. Restart the device. Back up the registry before editing; a mistake here can affect system behaviour.
  7. Verify the rule is active. Open Windows Security > Virus & threat protection > Manage settings > Manage Attack Surface Reduction rules (labels vary by version) and confirm the rule shows as Block. Alternatively, run Get-MpPreference in an elevated PowerShell window and look for the rule ID under AttackSurfaceReductionRules_Ids.
  8. Test with a harmless macro. Create a test document with a macro that calls a benign Win32 function such as GetUserName via Declare. With the rule set to Block, the macro should fail with a runtime error or a security warning. If it runs, the policy is not applied; recheck the path and restart.
  9. For managed fleets, deploy via Intune. In the Microsoft Endpoint Manager admin center, go to Endpoint security > Attack surface reduction and create a policy for the ASR rule above. Assign it to device groups and monitor the audit events before switching to Block.

Common Mistakes

  • Applying the rule only to the user configuration branch; ASR rules are computer-wide and belong under Computer Configuration.
  • Using the wrong rule GUID. The ID for blocking Win32 API calls from Office macros is specific; a typo silently disables the rule.
  • Setting the value to 0 (Disabled) instead of 1 (Block) or 2 (Audit).
  • Forgetting to restart Office or the device, then concluding the rule does not work.
  • Deploying straight to Block on a fleet without an audit period, which can break legitimate line-of-business macros.

Tips

  • Run in Audit mode for a week and review Defender events before switching to Block.
  • Combine this rule with other macro protections: block macros from the internet and disable Trust Bar bypass where policy allows.
  • Document any approved macros that rely on Win32 calls and move them to a signed, trusted location rather than weakening the policy.
  • Keep Windows and Office updated; ASR rule behaviour and management surfaces change between builds.

Troubleshooting

If the macro still runs after enabling the rule, first confirm the policy is actually applied: open an elevated Command Prompt and run gpresult /h report.html, then search the report for the rule ID. If it is missing, the policy is not linked to the device's organisational unit or the local policy was overridden by a domain policy. Next, check that Microsoft Defender Antivirus is the active antivirus; ASR rules rely on it, and third-party antivirus can interfere. Restart the device and retest. If the rule appears in policy but macros still execute, verify the Office build supports the rule and that the macro is not running from a trusted location that bypasses ASR. For Intune deployments, check the policy status per device and allow time for sync. If you see errors in Event Viewer under Microsoft-Windows-Windows Defender/Operational, note the event ID and consult Microsoft's ASR documentation rather than guessing at registry changes.

Frequently Asked Questions

Does this block all macros?

No. It blocks VBA macros that call Win32 API functions via Declare statements. Macros that only use built-in Office objects continue to run.

Will it break legitimate business macros?

Possibly, if those macros call Windows APIs. Test in Audit mode first and review the events before enforcing Block.

Can I use this on Windows Home?

The Group Policy Editor is not included, but the registry method works if your Windows build supports ASR rules. Check your build version first.

Is this the same as blocking macros from the internet?

No. Blocking internet macros is a separate Office setting. This rule targets the API-call technique inside macros that are already allowed to run.

How do I know the rule is working?

Check Windows Security or run Get-MpPreference in PowerShell, then test with a harmless macro that calls a Win32 function.

Does it affect other Office apps?

The rule applies to Office applications that host VBA, including Word, Excel and PowerPoint, depending on the Office build.