+ Reply to Thread
Results 1 to 11 of 11

Code Upgrade To Work in Both (32-64 bit)

  1. #1
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    905

    Code Upgrade To Work in Both (32-64 bit)

    Hello Again,

    I am using a script adopted from some website in year 2015 but I need to upgrade to work in both office 2007 and 2013.

    Below is the code and copy of old version file is attached.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Code Upgrade To Work in Both (32-64 bit)

    Hi, me here again this is all you need to change:

    Please Login or Register  to view this content.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Code Upgrade To Work in Both (32-64 bit)

    Hi hecgroups,

    I've never heard of this before but some searching finds:
    https://docs.microsoft.com/en-us/off...trsafe-keyword

    Let me know if Hans suggestion worked.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    905

    Re: Code Upgrade To Work in Both (32-64 bit)

    Hey Keeb,

    Thanks once again it works as I want let me check in both the versions and get back to you.
    Thank once again for your help.

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Code Upgrade To Work in Both (32-64 bit)

    Quote Originally Posted by MarvinP View Post
    Let me know if Hans suggestion worked.
    Hi Marvin,
    I ran into similar issues when a friend I was helping ran into compatibility issues and he came up with this.
    I've implemented it since and it was a lifesaver.

    You can use this type if If Then Else conditions with the hash also to check if the OS is MAC or Windows and many more.

  6. #6
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    905

    Re: Code Upgrade To Work in Both (32-64 bit)

    Thanks Keeb it works in both systems i.e. win 7 & 10 with office 2010 & 2013.

    I will mark topic as solved and reputation add to you both.

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Code Upgrade To Work in Both (32-64 bit)

    Good to hear and thanks for the rep.
    Happy coding

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Code Upgrade To Work in Both (32-64 bit)

    FYI, that code will not work properly in 64bit Office and is liable to crash.
    Remember what the dormouse said
    Feed your head

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Code Upgrade To Work in Both (32-64 bit)

    I suggest you should be more specific about this, why and the caveats.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Code Upgrade To Work in Both (32-64 bit)

    The caveat: if you get an API call wrong, it is liable to crash Excel without warning or chance to recover.

    The why is that you just added PtrSafe which is not enough. For example, FindWindow returns a window handle, which is a Long in 32bit but a LongLong in 64bit, so it should be declared as LongPtr to allow it to return whichever is necessary. That also means that you can't change just the API lines - you also need to make sure that the variables are declared correctly depending on the version.

    I do note though that the original post only mentions making the code work in both 2007 and 2013, whereas the title mentions 32 and 64bit, so it's not clear if the 2013 is, or may be, 64bit, or if it just needs to work in both versions at 32bit.
    Last edited by romperstomper; 05-05-2020 at 05:10 AM.

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Code Upgrade To Work in Both (32-64 bit)

    I don't have 64 bit here to test, but it should be something like this:

    Please Login or Register  to view this content.

+ 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. SCARY: IT tells me NO MACROS will work when we upgrade to 2013
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-10-2016, 09:21 AM
  2. Code does not work after Excel 2013 Upgrade
    By amalejko in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-16-2014, 01:56 PM
  3. [SOLVED] Increasing code speed by computer upgrade?
    By Imperial in forum Excel General
    Replies: 13
    Last Post: 06-22-2013, 02:58 PM
  4. Find - Replace - Sort: code upgrade
    By markos97 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-04-2012, 05:13 AM
  5. code doesnt work after upgrade to 2010
    By jmckee in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-12-2011, 09:57 AM
  6. Want to optimize and upgrade macro code
    By Bowzerbro in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-02-2009, 06:59 AM
  7. Linked files don't work after upgrade
    By couriced in forum Excel General
    Replies: 0
    Last Post: 10-19-2005, 12:35 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