VBA & Macro Problems

Fix Excel 2010 VBA Crashing After Upgrading to Windows 10

Emma BrownEmma Brown Oct 26, 2026 868 views

Question details

Users experience Excel 2010 closing unexpectedly or failing to run macros when editing a VBA module after an OS upgrade.

How to Fix Excel 2010 VBA Crashing After Upgrading to Windows 10
Product
Microsoft Excel 2010
Device & OS
Windows 10
Scenario
Opening the Visual Basic Editor or executing an existing macro after upgrading from Windows 7 to Windows 10.
Observed behavior
Excel 2010 (32-bit) crashes, freezes, or forcibly closes without warning, despite the macro trust settings being correctly configured.
Before you start

Verify whether your new Windows 10 installation is 32-bit or 64-bit, as migrating to a 64-bit operating system fundamentally changes how Windows API declarations must be formatted in your legacy VBA code.

Solution 1Recommended

Update VBA API Declarations for 64-bit Environments

Modify your Windows API declarations by adding PtrSafe and changing handle data types to LongPtr to ensure OS compatibility.

When moving from Windows 7 to a 64-bit Windows 10 environment, older API calls in VBA will trigger a crash if they are not updated. Even if Excel remains 32-bit, the OS handles memory differently.

1
Open the Visual Basic Editor

Press Alt + F11 on your keyboard to launch the VBA Editor in Excel.

2
Locate API Declarations

Check the top of your standard modules or UserForms for any lines starting with the word 'Declare'.

3
Add the PtrSafe Keyword

Modify the declaration by inserting 'PtrSafe' immediately after 'Declare' (e.g., 'Declare PtrSafe Function...').

4
Update Pointers to LongPtr

Identify any variables or return types that represent a pointer or a handle (such as hWnd) and change their data type from 'Long' to 'LongPtr'.

Update VBA API Declarations for 64-bit Environments
Save Before Testing: Always save your workbook immediately after updating the API declarations, before attempting to run the macro, to prevent data loss if a crash occurs again.
Free Microsoft Office alternative

Upgrade to WPS Office for Seamless Macro Compatibility

Struggling with legacy Excel 2010 crashes on modern operating systems? WPS Office offers a highly compatible, lightweight alternative that natively supports VBA macros on Windows 10 and 11 without constant troubleshooting.

Completely free and lightweight alternative to Microsoft OfficeHigh compatibility with legacy and modern Excel formats (.xls, .xlsx, .xlsm)Native support for complex VBA macros and scripts out of the boxFamiliar ribbon interface ensures zero learning curve when switching
microsoft office alternative - wps office

Frequently Asked Questions

Why does Excel 2010 crash immediately when I try to open the VBA editor?

This commonly happens when your VBA code contains 32-bit API declarations, and you run it on a 64-bit operating system. Upgrading to Windows 10 often switches users to a 64-bit environment, leading to memory access violations when legacy macros load.

What is the difference between Long and LongPtr in VBA code?

Long is a fixed 32-bit integer, while LongPtr is a dynamic variable type. LongPtr automatically resolves to 32 bits on a 32-bit system and 64 bits on a 64-bit system, making it essential for handling memory pointers safely on newer operating systems.

Will repairing Microsoft Office 2010 delete my existing macros?

No. Running an Online Repair or standard repair through the Windows Apps & Features menu only fixes the core application files. It does not overwrite your personal workbooks, templates, or the macros saved within them.