32-Bit vs. 64-Bit VBA: Handling Compatibility Issues
Ensure your code runs on both platforms.
API declarations
Use #If VBA7 Then and PtrSafe for 64-bit Office.
#If VBA7 Then Private Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long #Else Private Declare Function GetTickCount Lib "kernel32" () As Long #End If
LongPtr and pointers
Use LongPtr for pointer-sized values; avoid assuming 32-bit Long for handles.
Work faster with the VBA Assistant
Create, explain, and improve your VBA code with examples, comments, and best practices—directly in your workflow.
