none
62 bit error RRS feed

  • Question

  • I inherited a DB that has been working on windows 7 machines and assorted versions of Access for some time.   I have not had to do any modifications to it.  When moved recently to a windows 10 machine running office 365, it failed.  Error is below.


     

     

    I think the code it is failing on is reproduced below.  I have not even taken the time to figure out what this code does.  I did some research and have found a variety of material to wade through, have not had time to do so yet.

     

    Public Declare Function apiShellExecute Lib "shell32.dll" _

    Alias "ShellExecuteA" _

    (ByVal hwnd As Long, _

    ByVal lpOperation As String, _

    ByVal lpFile As String, _

    ByVal lpParameters As String, _

    ByVal lpDirectory As String, _

    ByVal nShowCmd As Long) _

    As Long

     

    Is there a quick simple fix anyone can think of?


    • Edited by tkosel Thursday, March 12, 2020 8:53 PM
    Thursday, March 12, 2020 8:52 PM

Answers

  • Change the declaration to

    #If VBA7 Then

    Private Declare PtrSafe Function apiShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
            ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, _
            ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr

    #Else

    Private Declare Function apiShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
            ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
            ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

    #End If


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by tkosel Friday, March 13, 2020 5:04 PM
    Thursday, March 12, 2020 9:23 PM

All replies

  • Change the declaration to

    #If VBA7 Then

    Private Declare PtrSafe Function apiShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
            ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, _
            ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr

    #Else

    Private Declare Function apiShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
            ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
            ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

    #End If


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by tkosel Friday, March 13, 2020 5:04 PM
    Thursday, March 12, 2020 9:23 PM
  • Hans,

    As usual, thanks for your response.  It was just the ticket.  What is "LongPtr"?

    Friday, March 13, 2020 5:06 PM
  • It is a data type that dynamically adjusts itself to the "bitness" of Office: in 32-bit Office, it is a 32-bit integer, and in 64-bit Office (which is installed on the computer where you had the problem), it is a 64-bit integer.

    See LongPtr data type


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Friday, March 13, 2020 5:16 PM
  • Hans,

    Again, thanks for your assistance.  What do I do with a boolean declaration?

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


    • Edited by tkosel Monday, March 16, 2020 10:15 PM
    Monday, March 16, 2020 10:10 PM
  • That can remain the same.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Monday, March 16, 2020 10:18 PM
  • But the definition of tagOPENFILENAME must be updated:

    #If VBA7 Then
        Public Type tagOPENFILENAME
            lStructSize As Long
            hwndOwner As LongPtr
            hInstance As LongPtr
            lpstrFilter As String
            lpstrCustomFilter As String
            nMaxCustFilter As Long
            nFilterIndex As Long
            lpstrFile As String
            nMaxFile As Long
            lpstrFileTitle As String
            nMaxFileTitle As Long
            lpstrInitialDir As String
            lpstrTitle As String
            flags As Long
            nFileOffset As Integer
            nFileExtension As Integer
            lpstrDefExt As String
            lCustData As LongPtr
            lpfnHook As LongPtr
            lpTemplateName As String
        End Type
    #Else
        Public Type tagOPENFILENAME
            lStructSize As Long
            hwndOwner As Long
            hInstance As Long
            lpstrFilter As String
            lpstrCustomFilter As String
            nMaxCustFilter As Long
            nFilterIndex As Long
            lpstrFile As String
            nMaxFile As Long
            lpstrFileTitle As String
            nMaxFileTitle As Long
            lpstrInitialDir As String
            lpstrTitle As String
            flags As Long
            nFileOffset As Integer
            nFileExtension As Integer
            lpstrDefExt As String
            lCustData As Long
            lpfnHook As Long
            lpTemplateName As String
        End Type
    #End If

    See https://jkp-ads.com/Articles/apideclarations.asp


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Monday, March 16, 2020 10:23 PM
  • Hans,

    Thanks again.

    How do I structure the code?I currently have:Question

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

    Where do I put all the stuff you posted?

    Sunday, March 22, 2020 2:29 PM
  • I assume that you currently have something like

        Public Type tagOPENFILENAME
            lStructSize As Long
            hwndOwner As Long
            hInstance As Long
            lpstrFilter As String
            lpstrCustomFilter As String
            nMaxCustFilter As Long
            nFilterIndex As Long
            lpstrFile As String
            nMaxFile As Long
            lpstrFileTitle As String
            nMaxFileTitle As Long
            lpstrInitialDir As String
            lpstrTitle As String
            flags As Long
            nFileOffset As Integer
            nFileExtension As Integer
            lpstrDefExt As String
            lCustData As Long
            lpfnHook As Long
            lpTemplateName As String
        End Type

    It's probably (but not necessarily) in the same module as in the declaration of aht_apiGetOpenFileName. You have to replace this block with the code from my previous reply.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Sunday, March 22, 2020 3:44 PM
  • Replace all:

    Declare Function

    with:

    Declare PtrSafe Function

    Sunday, March 22, 2020 9:08 PM
  • Hans and Lawrence,

    Thanks for your responses.  Lawrence's suggestion seems like a lot less effort if it will work.  Looking for feedback on which solution is best, problems and pitfalls of both methods.

    Sunday, March 22, 2020 9:46 PM
  • I think you need both.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Sunday, March 22, 2020 9:48 PM