+ Reply to Thread
Results 1 to 15 of 15

An upgrade to 64bit Office 2010 creates a function error in a standard module?

  1. #1
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    An upgrade to 64bit Office 2010 creates a function error in a standard module?

    An upgrade was done on the first of many computers in our ogranization; an 'upgrade' to a 64bit operating system, which caused the following error in one of my modules:

    "Complile 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 PtrSafe attribute."

    The code below is what the error applied to. I am thinking I have to change something on the .dll? Anyway, I am going to need the code to work on both 32bit and 64bit operating systems for some time. Any help is greatly appreciated!

    Please Login or Register  to view this content.
    Last edited by jonvanwyk; 01-05-2012 at 12:34 PM. Reason: Clarity

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: An upgrade to 64 bit operating system creates a function error in a standard modu

    That error is not related to a 64 bit operating system, but to using 64bit Office. I would suggest you read through this MSDN article. There is also a download available that lists many of the API declaration statements in both 32 and 64 bit syntax.
    Good luck.

  3. #3
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: An upgrade to 64 bit operating system creates a function error in a standard modu

    @onerrorgoto0: That is a good start at least to know that it is the version of Office and not the OS. My programming skills may not be sufficient to know on my own how to modify the delcaration statements to be compatible with both. So again, thank you to any one that can assist with this. I am sure it is probably something simple, I just have never done it before. I pride myself on just never having to ask the same question twice. It is how I learn

  4. #4
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: An upgrade to 64bit Office 2010 creates a function error in a standard module?

    I have been working on following through with OnErrorGoto0's suggestions, but I have insufficient administrative rights to run some of the stuff required to do it. any assistance offered with achieving resolution to this issue is greatly appreciated!

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: An upgrade to 64bit Office 2010 creates a function error in a standard module?

    In 64-bit Office VBA, you'll need to declare API calls this way:

    Please Login or Register  to view this content.


    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  6. #6
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: An upgrade to 64bit Office 2010 creates a function error in a standard module?

    You will also need to replace any pointer arguments so that they are LongPtr rather than Long. I will see if I can put it together for you shortly (if the forum remains up) but I do not have 64bit Excel to test on, I am afraid, so I will have to leave that to you.

  7. #7
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: An upgrade to 64bit Office 2010 creates a function error in a standard module?

    OK, based on the Microsoft documentation, I think the code should be:
    Please Login or Register  to view this content.
    Can you let me know if that works OK?

  8. #8
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: An upgrade to 64bit Office 2010 creates a function error in a standard module?

    If it should run on both 64 bit and older version you have to declare in an if statement.

    Please Login or Register  to view this content.
    When opening in 64 bit the else part will be marked with red and the other way round if it's not 64 bit.
    This is how it's supposed to be.
    Please take time to read the forum rules

  9. #9
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: An upgrade to 64bit Office 2010 creates a function error in a standard module?

    Strictly speaking, as in the MS article I linked to, you only need #Win64 if you are using 64bit specific code - e.g. code that uses LongLong. For the rest you only need the #VBA7 constant, since 32bit Office 2010 is fine with LongPtr and PtrSafe.

  10. #10
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: An upgrade to 64bit Office 2010 creates a function error in a standard module?

    @onErrorGoto0: Thank you very much for taking such time to assist me. I also do not have 64bit Office, so will have to wait to test your code on the computer that has it when it becomes available. I will keep you posted as I know more...and thank you again for your help!

  11. #11
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: An upgrade to 64bit Office 2010 creates a function error in a standard module?

    PtrSafe Compile Error.jpg

    I installed your code into module 3 of my workbook (where it was originally located before modification). Before I could text it on the 64bit Office, it gave me the attached Complile Error on my 32bit version. Thoughts?

  12. #12
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: An upgrade to 64bit Office 2010 creates a function error in a standard module?

    Per the article I linked to, if you do not have office 2010 you will need conditional compilation since VBA6 has no concept of PtrSafe or any 64bit compatibility issues.

  13. #13
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: An upgrade to 64bit Office 2010 creates a function error in a standard module?

    I am sorry. I have attempted multiple ways of accomplishing this, but am still at a loss. :-/

  14. #14
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: An upgrade to 64bit Office 2010 creates a function error in a standard module?

    Try this

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: An upgrade to 64bit Office 2010 creates a function error in a standard module?

    I will see if it works. Thanks again for helping me out!

+ 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