+ Reply to Thread
Results 1 to 12 of 12

PtrSafe attribute for 64 bit system

  1. #1
    Forum Contributor
    Join Date
    03-10-2014
    Location
    Sheffield
    MS-Off Ver
    Excel 2010
    Posts
    180

    PtrSafe attribute for 64 bit system

    I have written some code in Excel at work but when I try to use at home it comes up with this message:-


    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.

    The code I have is as follows:

    Please Login or Register  to view this content.
    What do I need to do?!

    Thanks
    MissD

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: PtrSafe attribute for 64 bit system

    Hi MissDB,

    Try the following:
    Please Login or Register  to view this content.
    The following is one of many references for 32 bit vs 64 bit compatibility:
    http://www.jkp-ads.com/articles/apideclarations.asp

    Lewis
    Last edited by LJMetzger; 04-03-2014 at 07:29 AM. Reason: 64 bit nBufferLength was longptr in error (now Long)

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: PtrSafe attribute for 64 bit system

    nbufferlength is actually long not longptr ;-)
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Forum Contributor
    Join Date
    03-10-2014
    Location
    Sheffield
    MS-Off Ver
    Excel 2010
    Posts
    180

    Re: PtrSafe attribute for 64 bit system

    Hi,

    Thanks for this. JosephP what do you mean?

    How would you write the code?

    Thanks
    Davinia

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: PtrSafe attribute for 64 bit system

    I'd use
    Please Login or Register  to view this content.
    or if you only use excel 2010 or later just use
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    03-10-2014
    Location
    Sheffield
    MS-Off Ver
    Excel 2010
    Posts
    180

    Re: PtrSafe attribute for 64 bit system

    Brilliant thank you so much. Will give it a go and let you know how I get on

  7. #7
    Forum Contributor
    Join Date
    03-10-2014
    Location
    Sheffield
    MS-Off Ver
    Excel 2010
    Posts
    180

    Re: PtrSafe attribute for 64 bit system

    Hi,

    It didn't work It says run time error 5 invalid procedure call or argument and the code stops at this point:-

    Please Login or Register  to view this content.
    GetTmpPath = Left(sFolder, InStr(sFolder, _
    Chr(0)) - 1)
    Please Login or Register  to view this content.

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: PtrSafe attribute for 64 bit system

    This is an example from Excel 2010 Power Programming with VBA by John Walkenbach.

    Please Login or Register  to view this content.
    I hope that I didn't make any typos.....I'm not used to this.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: PtrSafe attribute for 64 bit system

    Quote Originally Posted by MissDB View Post
    Hi,

    It didn't work It says run time error 5 invalid procedure call or argument and the code stops at this point:-

    Please Login or Register  to view this content.
    GetTmpPath = Left(sFolder, InStr(sFolder, _
    Chr(0)) - 1)
    Please Login or Register  to view this content.
    I tested the code a few times and it works. you'd only get that error if there isn't a chr(0) in the temp path but it should always be terminated with a null character. what operating system version do you have - vista / 7/ 8?

  10. #10
    Forum Contributor
    Join Date
    03-10-2014
    Location
    Sheffield
    MS-Off Ver
    Excel 2010
    Posts
    180

    Re: PtrSafe attribute for 64 bit system

    At home it's Windows 8, at work it is Windows 7 Enterprise.

  11. #11
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: PtrSafe attribute for 64 bit system

    I'll test win8 later - gotta get some sleep now!

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: PtrSafe attribute for 64 bit system

    Win8 works for me, the only way I can replicate the error at that place is by removing the MAX_PATH contsant

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] ChangeFormat of column from English decimal system with a dot to French System with a ,
    By rajiv1988 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2013, 04:31 AM
  2. [SOLVED] Automated machine order pricing system system
    By Sherburn Systems in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-19-2012, 10:14 AM
  3. USER FORMS NOT WORK AT SYSTEM 32 Bits AND SYSTEM 64Bits
    By Flash_Azul in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-16-2011, 08:02 PM
  4. USER FORMS NOT WORK AT SYSTEM 32 Bits AND SYSTEM 64Bits
    By Flash_Azul in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-09-2011, 03:16 AM
  5. [SOLVED] excel causing system to be in low system resource
    By inenewbl in forum Excel General
    Replies: 0
    Last Post: 04-05-2005, 12:06 PM

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