Consulting

Results 1 to 6 of 6

Thread: Change VBA code to fit 64-bit environment

  1. #1

    Change VBA code to fit 64-bit environment

    Following declarations from my earlier 32-bit environment must be corrected, but I dont know how. Please help...

    Declare Function FindWindowByClass Lib "user32" Alias _
    "FindWindowA" (ByVal lpClassName As String, ByVal _
    lpWindowName As Long) As Long
    
    
    Declare Function RegisterWindowMessage Lib "user32" Alias _
    "RegisterWindowMessageA" (ByVal lpstring As String) As Long
    
    
    Declare Function FindWindow Lib "user32" Alias _
    "FindWindowA" (ByVal lpClassName As Any, ByVal _
    lpWindowName As Any) As Long
    
    
    Declare Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hwnd As Long, ByVal _
    wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Last edited by Paul_Hossler; 11-04-2017 at 12:59 PM.

  2. #2
    VBAX Master mancubus's Avatar
    Joined
    Dec 2010
    Location
    where i lay my head is home
    Posts
    2,484
    Declare PtrSafe Function FindWindowByClass Lib "user32" Alias _
    "FindWindowA" (ByVal lpClassName As String, ByVal _
    lpWindowName As Long) As LongPtr
     
     
    Declare PtrSafe Function RegisterWindowMessage Lib "user32" Alias _
    "RegisterWindowMessageA" (ByVal lpstring As String) As LongPtr
     
     
    Declare PtrSafe Function FindWindow Lib "user32" Alias _
    "FindWindowA" (ByVal lpClassName As Any, ByVal _
    lpWindowName As Any) As LongPtr
     
     
    Declare PtrSafe Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hwnd As Long, ByVal _
    wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPtr
    http://www.jkp-ads.com/articles/apideclarations.asp
    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Voluntary helpers do not need the whole workbook.

    3) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    Tanks!

  4. #4
    VBAX Master mancubus's Avatar
    Joined
    Dec 2010
    Location
    where i lay my head is home
    Posts
    2,484
    you are welcome. if you are sorted, pls mark the thread as solved for future references.
    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Voluntary helpers do not need the whole workbook.

    3) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  5. #5
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    Not far
    Posts
    1,496
    The SendMessage one should be:

    Public Declare PtrSafe Function SendMessageA Lib "user32" (ByVal hWnd As LongPtr, ByVal wMsg As Long, _
                                                               ByVal wParam As LongPtr, lParam As Any) As LongPtr
    Be as you wish to seem

  6. #6
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,515
    Location
    JKP's link is a good one to show several of those and how to do both types.

    Since this has so many views, some might like those listed at.
    https://support.microsoft.com/en-us/...64-bit-support

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •