logo
search
VBA & Macro Problems

How to Convert 32-Bit VBA Code to 64-Bit in Microsoft Access

Amos GikundaAmos Gikunda Oct 15, 2026 870 views

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.

How to Convert 32-Bit VBA Code to 64-Bit in Microsoft Access
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 you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Launch your Microsoft Access database and press ALT + F11 on your keyboard to open the Visual Basic for Applications (VBA) Editor.

2
Locate API Declarations

Search through your standard modules to find existing Windows API 'Declare' statements.

3
Add the PtrSafe Keyword

Insert the 'PtrSafe' attribute immediately following the 'Declare' keyword (for example, change 'Declare Function' to 'Declare PtrSafe Function').

4
Update Data Types to LongPtr

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'.

Update Windows API Declarations with PtrSafe and LongPtr
Understanding LongPtr: LongPtr is not a strict data type, but a VBA macro that automatically resolves to a 32-bit Long on 32-bit systems and a 64-bit LongLong on 64-bit systems, ensuring perfect cross-compatibility.
Free Microsoft Office alternative

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. 1. Download the Installer: Visit the official WPS Office website and click the download button to get the free installer.
  2. 2. Install WPS Office: Run the downloaded setup file and follow the simple on-screen instructions to install the suite on your computer.
  3. 3. Open Your Macro Files: Launch WPS Spreadsheets to directly open your .xlsm files and seamlessly manage your VBA macros.
Fully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx, .xlsm).Includes a robust, built-in VBA editor in WPS Spreadsheets for running and editing macros.Lightweight architecture ensures quick installation and minimal system resource consumption.Completely free to use with a familiar, easy-to-navigate tabbed interface.
microsoft office alternative - wps office

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.