Excel VBA Not Working After Windows 11 Upgrade — Complete Fix Guide

May 30, 2026 · 14 min read

You upgraded to Windows 11. Now your Excel macros are broken, your VBA code throws compile errors, and workbooks that ran flawlessly for years suddenly do nothing when you click the button. You are not alone — this is one of the most common issues IT teams and power users face after a Windows 11 migration.

The problem is that a Windows 11 upgrade changes multiple things at once: your Office installation may have silently switched from 32-bit to 64-bit, your Trust Center settings may have been reset, library references your VBA code depends on may have vanished, and new security policies may be actively blocking macros and ActiveX controls. Any one of these will break your macros. Most people hit two or three simultaneously.

This guide covers every cause and gives you the exact fix for each one. Work through the diagnostic checklist below, and your macros will be running again.

Quick Diagnostic Checklist

Before diving into individual fixes, run through this checklist to identify which issues apply to you. Check each item in order — earlier items are more common causes.

Now let's fix each one.

Cause 1: Office Switched from 32-bit to 64-bit

This is the number-one reason VBA breaks after a Windows 11 upgrade. When you install Microsoft 365 or Office 2021 on a fresh Windows 11 system, the installer defaults to 64-bit Office. If your previous Windows 10 machine ran 32-bit Office (which was the default for years), every VBA module with Win32 API Declare statements will fail immediately.

How to confirm

  1. Open Excel
  2. Click File > Account > About Excel
  3. The first line shows your version number followed by either (32-bit) or (64-bit)

If it says 64-bit and your code was written for 32-bit, you have found the root cause of most of your errors.

How to fix it

You have two options:

Option A: Fix your VBA code for 64-bit compatibility (recommended). This means adding the PtrSafe keyword to every Declare statement and replacing Long with LongPtr for pointer and handle arguments. We cover this in detail in the next section, and our dedicated guide walks through every common API declaration: VBA PtrSafe Fix for Windows 11.

Option B: Reinstall 32-bit Office. You can uninstall your current Office and download the 32-bit version from your Microsoft 365 admin portal (choose "Other install options" > select 32-bit). This avoids code changes but is a temporary solution — Microsoft is moving toward 64-bit as the default across the board.

Cause 2: PtrSafe Keyword Missing from Declare Statements

If you are running 64-bit Office, every Declare Function and Declare Sub statement in your VBA code must include the PtrSafe keyword. Without it, the VBA compiler refuses to even open the module — you get a compile error before any code runs.

The error you see

"Compile error: The code in this project must be updated for use on 64-bit systems. Review and update Declare statements and then mark them with the PtrSafe attribute."

Before (breaks on 64-bit)

Declare Function GetTickCount Lib "kernel32" () As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

After (works on both 32-bit and 64-bit)

#If VBA7 Then
    Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long
    Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" _
        (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
#Else
    Declare Function GetTickCount Lib "kernel32" () As Long
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
        (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#End If

The #If VBA7 conditional compilation block ensures your code works on both old and new Office versions. Use LongPtr in place of Long for any argument that represents a pointer, handle, or memory address (like hWnd).

For a full list of common Win32 API declarations and their corrected 64-bit versions, see our detailed guide: VBA PtrSafe Fix for Windows 11.

If you are also seeing "Compile error: Hidden module" when opening the workbook, that usually points to the same PtrSafe issue in a module that Excel cannot display. See Compile Error in Hidden Module — Excel Fix for that specific scenario.

Cause 3: Broken VBA References (DAO 3.6, ADODB, and Others)

VBA projects reference external libraries (COM/ActiveX DLLs and type libraries) for database access, file operations, and other functionality. When you upgrade to Windows 11 with a new Office installation, some of these libraries change location, change version, or disappear entirely.

How to check

  1. Open your workbook and press Alt+F11 to open the VBA Editor
  2. Go to Tools > References
  3. Look for any reference with "MISSING:" in front of its name

The most common broken references

Missing Reference Replace With
Microsoft DAO 3.6 Object Library Microsoft Office 16.0 Access Database Engine Object Library
Microsoft ActiveX Data Objects 2.x Microsoft ActiveX Data Objects 6.1 Library
Microsoft Office 14.0 / 15.0 Object Library Microsoft Office 16.0 Object Library
Microsoft Scripting Runtime (scrrun.dll) Usually still available — uncheck and re-check to re-register
Microsoft Common Dialog Control 6.0 Not available in 64-bit — replace with Application.FileDialog

How to fix

  1. In the References dialog, uncheck the missing reference
  2. Scroll through the available list and check the correct replacement
  3. Click OK and recompile (Debug > Compile VBAProject)

The DAO 3.6 issue is especially common in workbooks that connect to Access databases. For a complete walkthrough of that specific fix, including the code changes required, see Missing DAO Reference Fix for VBA in Excel and Access.

Skip the manual diagnosis

LegacyLeaps scans your Excel files and identifies every compatibility issue automatically — free. PtrSafe errors, broken references, ActiveX problems, format issues — all in one report.

Try the Free Scan

Cause 4: Trust Center Macro Settings Were Reset

Windows 11 upgrades frequently reset Excel's Trust Center to more restrictive defaults. If your macros ran without prompts before and now they silently do nothing, this is probably why.

How to check and fix

  1. Open Excel and go to File > Options > Trust Center > Trust Center Settings
  2. Click Macro Settings
  3. Check the current setting:
    • "Disable all macros without notification" — macros are completely blocked with no prompt. This is the most restrictive and is often set by enterprise group policy after upgrades.
    • "Disable all macros with notification" — you get the yellow "Enable Content" bar. This is the recommended setting for most users.
    • "Disable all macros except digitally signed macros" — only macros signed with a trusted certificate will run. If your macros are unsigned, they are blocked.
  4. Select "Disable all macros with notification" and click OK

Trusted Locations

A better long-term approach for internal workbooks is to add your file directories to Trusted Locations:

  1. In Trust Center Settings, click Trusted Locations
  2. Click Add new location
  3. Browse to the folder where your macro-enabled workbooks live
  4. Check "Subfolders of this location are also trusted" if needed
  5. Click OK

Files in Trusted Locations run macros automatically without any prompt or security warning.

Group Policy override

If the macro settings are grayed out, your organization's IT department has enforced a Group Policy that controls macro behavior. You will need to contact your IT admin to either adjust the policy or add your files to an approved location. The relevant GPO setting is: User Configuration > Administrative Templates > Microsoft Excel > Trust Center > VBA Macro Notification Settings.

Cause 5: Protected View Blocking Macro Execution

Protected View is a read-only sandbox that prevents macros from running. After a Windows 11 upgrade, files can get flagged as "from the internet" or "from an unsafe location" even if they were always local files. This happens because Windows tracks a hidden NTFS attribute called the Mark of the Web (MOTW), and file copies during the upgrade process can trigger it.

Symptoms

How to fix individual files

  1. Close the file in Excel
  2. Right-click the file in File Explorer and select Properties
  3. At the bottom of the General tab, look for "This file came from another computer and might be blocked to help protect this computer"
  4. Check Unblock and click OK
  5. Reopen the file — Protected View should no longer trigger

How to fix in bulk (PowerShell)

# Unblock all Excel files in a directory
Get-ChildItem -Path "C:\MyWorkbooks" -Recurse -Include *.xls,*.xlsx,*.xlsm |
    Unblock-File

How to adjust Protected View settings

If you trust all files on your local machine:

  1. Go to File > Options > Trust Center > Trust Center Settings > Protected View
  2. Uncheck "Enable Protected View for files originating from the Internet"
  3. Uncheck "Enable Protected View for files located in potentially unsafe locations"
  4. Click OK

Be cautious with this approach — it reduces security for all files, not just your trusted ones. Trusted Locations (see above) is a safer alternative.

Cause 6: ActiveX Controls Blocked or Broken

If your workbook uses ActiveX controls — command buttons, combo boxes, list boxes, toggle buttons, or other controls from the Control Toolbox — they may stop working entirely after a Windows 11 upgrade. This happens for two reasons:

How to check ActiveX settings

  1. Go to File > Options > Trust Center > Trust Center Settings > ActiveX Settings
  2. If it says "Disable all controls without notification", change it to "Prompt me before enabling all controls with minimal restrictions"

How to fix the "ActiveX component can't create object" error

If the error is caused by a missing or incompatible OCX/DLL, you need to find a 64-bit version of that component or replace the control with a native VBA alternative. For a full guide to diagnosing and resolving this error, see ActiveX Component Can't Create Object — Fix Guide.

Common replacements for deprecated ActiveX controls:

Broken ActiveX Control Native VBA Replacement
Common Dialog (comdlg32.ocx) Application.FileDialog or Application.GetOpenFilename
Microsoft Web Browser Open URL with Shell or use a UserForm with WebBrowser control
Microsoft Calendar Control MonthView control or a custom UserForm date picker
Third-party grid controls ListObject (structured table) or MSForms ListView

Cause 7: File Format Issues (.xls vs .xlsm)

This is more subtle but catches people off guard. If your macro-enabled workbooks are still in the old .xls format (Excel 97-2003), they may behave differently on Windows 11 with modern Office. The .xls format runs in compatibility mode, which can mask certain errors on 32-bit Office but expose them on 64-bit Office.

Additionally, if someone saved a macro-enabled .xls file as .xlsx (without macros) during the upgrade process, all VBA code was silently stripped. The file opens fine, but the macros are simply gone.

How to check

For a deeper explanation of what changed between these formats and why it matters, see XLS vs XLSX — What Changed and Why It Matters.

The Complete Fix Workflow

Here is the recommended order of operations to fix everything at once:

  1. Determine your Office bitness (File > Account > About Excel). Write it down.
  2. Fix Trust Center settings — set macros to "Disable with notification," add Trusted Locations for your workbook folders.
  3. Unblock files — right-click > Properties > Unblock for individual files, or use the PowerShell command for bulk unblocking.
  4. Fix Protected View — adjust settings or use Trusted Locations.
  5. Open the VBA Editor (Alt+F11) and go to Tools > References. Fix any MISSING references.
  6. Search for Declare statements (Ctrl+F, search all modules). Add PtrSafe keyword and update data types if running 64-bit Office.
  7. Check ActiveX controls — test every button and control on every sheet. Replace broken OCX controls with native alternatives.
  8. Recompile — Debug > Compile VBAProject. Fix any remaining errors.
  9. Save as .xlsm if the file is still in .xls format.
  10. Test thoroughly — run every macro, click every button, test every form.

When You Have Dozens (or Hundreds) of Files

The manual process above works fine for one or two workbooks. But if you are an IT team managing a Windows 11 rollout across an organization, you might have dozens, hundreds, or thousands of macro-enabled workbooks that need to be checked and fixed.

Manually opening each file, checking references, searching for Declare statements, and testing ActiveX controls is not feasible at scale. This is exactly the problem LegacyLeaps was built to solve.

LegacyLeaps scans your entire file inventory and produces a detailed compatibility report for every file, identifying:

Preventing This from Happening Again

Future Windows updates and Office version changes will continue to introduce compatibility challenges. Here is how to protect your VBA investments going forward:

Fix your files before the next upgrade breaks them

Download LegacyLeaps and scan your Excel files for free. See every VBA compatibility issue in one report — before your users start filing tickets.

Use promo code FIRSTFILE for a free conversion on your first file.

Download Free Scanner

Related Resources

Get tips like this in your inbox

Practical fixes for legacy Excel and Access problems. No spam.

← Back to all posts