Fix Excel 2010 VBA Crashing After Upgrading to Windows 10
Question details
Users experience Excel 2010 closing unexpectedly or failing to run macros when editing a VBA module after an OS upgrade.

- 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.
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.
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.
Press Alt + F11 on your keyboard to launch the VBA Editor in Excel.
Check the top of your standard modules or UserForms for any lines starting with the word 'Declare'.
Modify the declaration by inserting 'PtrSafe' immediately after 'Declare' (e.g., 'Declare PtrSafe Function...').
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'.

Run an Online Repair for Office 2010
Repair your Microsoft Office installation to replace corrupted or missing core files caused during the Windows 10 upgrade process.
Test Excel in Safe Mode and Disable Add-ins
Launch Excel in Safe Mode to isolate whether third-party add-ins are interfering with VBA execution on Windows 10.
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.

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.




