简体   繁体   中英

Deploying 32-bit Access system to 64-bit Office machine

I'm compiling my Access database from a 32-bit Office machine running Access 2010. I'm deploying as an .accdr file for use in Access 2010 Runtime. My references are:

VBE7.DLL

MSACC.OLB

stdole2.tlb

ACEDAO.DLL

EXCEL.EXE

msxml6.dll

I will need to deploy to a range of platforms, including 64-bit 2010, 2013 and so on.

I take it there is no problem with most of the references as the deployed system will be using Access 2010 Runtime. However, Excel will give me a problem. I had tried registering the Excel reference (in fact all references, just in case any any other version differed by machine) on the fly, but it seems I can't register a 64-bit version of Excel from a 32-bit system. Or can I?

Also, would I still need to make changes to API calls (using the PtrSafe keyword) if I'm using Runtime 2010?

Here are some of the API calls I make:

Declare Function aht_apiGetOpenFileName Lib "comdlg32.dll" 
    Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean

Private Declare Function apiGetLocaleInfo Lib "kernel32" 
    Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long

Private Declare Function LoadLibraryRegister Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName$) As Long

Public Declare Function SetDllDirectoryA Lib "kernel32" (ByVal lpPathName As String) As Long

Private Declare Function GetProcAddressRegister Lib "kernel32" Alias _
"GetProcAddress" (ByVal hModule&, ByVal lpProcName$) As Long

Private Declare Function CreateThreadForRegister Lib "kernel32" Alias "CreateThread" (lpThreadAttributes As Any, ByVal dwStackSize&, ByVal lpStartAddress&, ByVal lpparameter&, ByVal dwCreationFlags&, ThreadID&) As Long

You need to make sure that the code is capable of running on both environments. So you could use as me how has suggested Conditional Compiling.

I normally use all the Library calls in a standard module. You should be able to do it something along the lines of:

#If Win64 = 1 And VBA7 = 1 Then
    Declare PtrSafe Function aht_apiGetOpenFileName Lib "comdlg32.dll" 
        Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean

    Private Declare PtrSafe Function apiGetLocaleInfo Lib "kernel32" 
        Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long

    Private Declare PtrSafe Function LoadLibraryRegister Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName$) As Long

    Public Declare PtrSafe Function SetDllDirectoryA Lib "kernel32" (ByVal lpPathName As String) As Long

    Private Declare PtrSafe Function GetProcAddressRegister Lib "kernel32" Alias _
    "GetProcAddress" (ByVal hModule&, ByVal lpProcName$) As Long

    Private Declare PtrSafe Function CreateThreadForRegister Lib "kernel32" Alias _
    "CreateThread" (lpThreadAttributes As Any, ByVal dwStackSize&, ByVal lpStartAddress&, _
    ByVal lpparameter&, ByVal dwCreationFlags&, ThreadID&) As Long
#Else
    Declare Function aht_apiGetOpenFileName Lib "comdlg32.dll" 
        Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean

    Private Declare Function apiGetLocaleInfo Lib "kernel32" 
        Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long

    Private Declare Function LoadLibraryRegister Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName$) As Long

    Public Declare Function SetDllDirectoryA Lib "kernel32" (ByVal lpPathName As String) As Long

    Private Declare Function GetProcAddressRegister Lib "kernel32" Alias _
    "GetProcAddress" (ByVal hModule&, ByVal lpProcName$) As Long

    Private Declare Function CreateThreadForRegister Lib "kernel32" Alias _
    "CreateThread" (lpThreadAttributes As Any, ByVal dwStackSize&, ByVal lpStartAddress&, _
    ByVal lpparameter&, ByVal dwCreationFlags&, ThreadID&) As Long
#End If

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM