none
32 bit and 64 bit code RRS feed

  • Question

  • i need to add code to allow both 32 and 64 bit

    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
        ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Const VK_SNAPSHOT = 44
    Const VK_LMENU = 164
    Const KEYEVENTF_KEYUP = 2
    Const KEYEVENTF_EXTENDEDKEY = 1


    Jim Neely

    Tuesday, February 17, 2015 1:24 PM

All replies

  • At the least, you need to add PtrSafe to your declaration:

    Private Declare PtrSafe Sub keybd_event....

    but a lot of 64 bit systems may lack 32 bit files, or their replacement files may not exist.

    Tuesday, February 17, 2015 3:02 PM
  • For a good article on 32/64 bit handling see:

    http://www.jkp-ads.com/articles/apideclarations.asp

    Use the #VBA7 code to handle 32 bit and 64 bit.


    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Tuesday, February 17, 2015 8:00 PM
  • Thanks for the replay. The article you refer is for 2010 32 bit vs 64 bit VBA 7. Would this apply to 2003 vba 6.

    Jim Neely


    • Edited by STARFALLS Thursday, February 19, 2015 6:46 AM
    Thursday, February 19, 2015 6:45 AM
  • No. That #VBA7 code is only for Office 2010+

    So which version and service pack of Windows are you running? And you do have SP3 for Office 2003?I think PtrSafe is 2010+ as well. Please always state program version and service pack level. Lot of time has been wasted giving wrong advice for your Office version.

    I suspect you need to do some serious searching on the Internet and you may not be lucky. Depending on number of users it may be cheaper just to upgrade to Office 2010 or 2013.


    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Friday, February 20, 2015 4:46 AM
  • "Thanks for the replay. The article you refer is for 2010 32 bit vs 64 bit VBA 7. Would this apply to 2003 vba 6?"

    ->Yes, it does apply.

    Felipe Costa Gualberto - http://www.ambienteoffice.com.br

    Friday, February 20, 2015 10:09 PM
  • Yeah that's my bad.... I do know better. At my level you did not waste your time. I went back and tried different things because of your interest. Thanks so much for your help. It is greatly appreciated.

    Jim Neely

    Saturday, February 21, 2015 2:25 AM
  • Thanks, for your reply. If this is so, I keep getting a error on "Sub" and it does not matter if it is in the WIN code or the VBA7 code. Idea ??

    Jim Neely

    Saturday, February 21, 2015 3:53 AM
  • Re:  API declaration

    My API viewer says the Sub should be...
    Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, _
                                 ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    '---

    Jim Cone
    Portland, Oregon USA
    https://goo.gl/IUQUN2 (Dropbox)
    (free & commercial excel add-ins & workbooks)

    • Edited by James Cone Sunday, October 30, 2016 11:34 PM
    Saturday, February 21, 2015 4:46 AM
  • My problem is a compile error "expected End of Line"

    Jim Neely

    Sunday, February 22, 2015 3:28 AM