How to Convert 32-Bit VBA Code to 64-Bit in Microsoft Access
Question details
The user needs to understand the required steps and considerations for migrating an Access database and its VBA code from a 32-bit architecture to a 64-bit architecture without causing compatibility issues.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Upgrading Microsoft Office or Access from a 32-bit version to a 64-bit version and needing to ensure existing VBA macros, particularly those with API calls, continue to function properly.
- Observed behavior
- The goal is to successfully modify API declarations, utilize the LongPtr data type, and apply conditional compilation so the database and macros run natively in 64-bit Access.
Before beginning the conversion process, verify whether you are currently running a 32-bit or 64-bit version of Microsoft Office and create a complete backup of your Microsoft Access database (.accdb or .mdb) to prevent accidental data loss.
Update Windows API Declarations with PtrSafe and LongPtr
The most critical step in migrating to 64-bit VBA is updating Windows API calls to safely handle 64-bit memory addresses.
When migrating from 32-bit to 64-bit Access, memory pointers and handles require 64 bits instead of 32. To prevent runtime errors, you must explicitly declare that your API functions are safe to run in a 64-bit environment.
Launch your Microsoft Access database and press ALT + F11 on your keyboard to open the Visual Basic for Applications (VBA) Editor.
Search through your standard modules to find existing Windows API 'Declare' statements.
Insert the 'PtrSafe' attribute immediately following the 'Declare' keyword (for example, change 'Declare Function' to 'Declare PtrSafe Function').
Review the parameters and return types of your API functions. Change any variable data types that represent memory pointers or handles from 'Long' to 'LongPtr'.

Implement Conditional Compilation for Cross-Version Support
Use this method if your Access database must be distributed and run seamlessly on both 32-bit and 64-bit Office installations.
Discover WPS Office: A Powerful and Free Office Suite
While updating VBA code for 64-bit Microsoft Access requires technical configuration, managing your daily documents, spreadsheets, and presentations should be effortless. WPS Office provides a highly compatible, lightweight alternative to Microsoft Office, featuring built-in VBA support to seamlessly handle your macro-enabled spreadsheet tasks.
- 1. Download the Installer: Visit the official WPS Office website and click the download button to get the free installer.
- 2. Install WPS Office: Run the downloaded setup file and follow the simple on-screen instructions to install the suite on your computer.
- 3. Open Your Macro Files: Launch WPS Spreadsheets to directly open your .xlsm files and seamlessly manage your VBA macros.

Frequently Asked Questions
What happens if I do not update my 32-bit VBA code in 64-bit Access?
If you try to run unmodified 32-bit VBA code containing API declarations in a 64-bit version of Microsoft Access, the code will fail to compile. You will receive an error stating: 'The code in this project must be updated for use on 64-bit systems', and the macros will not run.
Is LongLong the exact same as LongPtr in VBA?
No. LongLong is a strict 64-bit integer data type that is exclusively available in 64-bit Office. LongPtr is a dynamic alias that automatically resolves to Long in 32-bit Office and LongLong in 64-bit Office, making it the best choice for writing cross-compatible code.
Do standard VBA macros without API calls need conversion for 64-bit?
Generally, no. Standard VBA macros that do not interact directly with the Windows API, memory pointers, or third-party 32-bit DLLs will run natively in 64-bit Microsoft Access without requiring any modifications.
Can I run 32-bit ActiveX controls in 64-bit Microsoft Access?
No, a 64-bit application like 64-bit Microsoft Access cannot load or execute 32-bit ActiveX controls (.ocx files) or 32-bit DLLs. You must obtain the 64-bit versions of these controls from the original vendor or find modern 64-bit alternatives.




