+ Reply to Thread
Results 1 to 9 of 9

Problem with code using 64 bit system

  1. #1
    Forum Contributor
    Join Date
    12-16-2004
    Posts
    125

    Problem with code using 64 bit system

    I have just started using a 64 bit laptop. I get an unusual error involving a Private Declare Function only on the 64 bit system. The error says, "Compile error: The code in this project must be updated for use on 64-bit systems. Please review and update Declare statements and then mark them with the PtrSafe attribute." I am unsure how to fix this problem and was hoping someone could help. Here is the code that is highlighted after the error:
    Please Login or Register  to view this content.
    I am still very new to Visual Basic and can't figure this out. Any help is appreciated.

    Thanks.
    Last edited by CJ-22; 05-10-2013 at 10:30 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Problem with code using 64 bit system

    I don't know for sure, but can you change kernel32 to kernel64?

  3. #3
    Forum Contributor
    Join Date
    12-16-2004
    Posts
    125

    Re: Problem with code using 64 bit system

    Thanks for the suggestions, but I still get the same error.

  4. #4
    Registered User
    Join Date
    12-18-2012
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Problem with code using 64 bit system

    Try changing long to Longptr, see here http://msdn.microsoft.com/en-us/libr.../gg264421.aspx

    hope this helps

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Problem with code using 64 bit system

    Hello CJ-22,

    This will work...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Problem with code using 64 bit system

    Why not just use VBA's native ChDrive and ChDir instead of API?
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Contributor
    Join Date
    12-16-2004
    Posts
    125

    Re: Problem with code using 64 bit system

    Thanks for all the help. I simply added "PtrSafe" before Function and the error went away.

    Please Login or Register  to view this content.
    Don't know why, but it now works. Thanks for all the help.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Problem with code using 64 bit system

    Begs the question, but congratulations.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Problem with code using 64 bit system

    Hello CJ-22,

    Calls to 64-bit Windows API functions from 32-bit solutions (and the opposite) may lead to erratic behavior or system crashes resulting from the truncation of data or overflows into protected memory spaces. To ensure this does not happen, you should use the PtrSafe keyword. in the Declarations statement. Declare statements that include PtrSafe work correctly in the VBA7 development environment on both 32-bit and 64-bit platforms only after all data types in the Declare statement (parameters and return values) that need to store 64-bit quantities are updated to use LongLong for 64-bit integrals or LongPtr for pointers and handles.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1