Excel VBA AI Assistant LogoExcel VBA AI Assistant
    Pain Points
    VBA
    Compatibility
    64-Bit
    Featured

    32-Bit vs. 64-Bit VBA: Handling Compatibility Issues

    Write VBA that works on 32-bit and 64-bit Office: PtrSafe declarations and LongPtr usage.

    VBA AI Team
    Published on August 17, 2025
    13 min read

    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.