Running VBA Code created in "32 bit Excel" on Windows 10 "64 bit Environment"

Anonymous
2020-12-02T18:42:24+00:00

Dear Colleagues,

Hope you are doing,

Running VBA code created in 32 bit excel version 2016, meanwhile I moved to 64 bit Windows Version but excel version still 32bit. 

After moving to 64bit Windows 10, I’m getting a lot of (Run time error 13 & Run time error 91 object variable or with block variable not set). VBA run in Internet Explorer (IE 11), also I tied to add DoEvent & Application.wait, but sometimes it’s working and sometimes is not. (Library is referred to WOW64).

More information below:

  1. Old Laptop:
    • Windows 7 (32bit)
    • Excel Version 2016 (32bit)
    • IE 11
  2. New Laptop:
    • Windows 10 (64bit)
    • Excel Version 2016 (32bit)
    • IE 11

Do you think its Version of office or internet explorer ?

Thanks for your attention. I’m looking forward to your Suggestions.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} vote

6 answers

Sort by: Most helpful
  1. Andreas Killer 144K Reputation points Volunteer Moderator
    2020-12-04T10:24:36+00:00

    Do you think its Version of office or internet explorer ?

    It is clearly your code and the security architecture of Windows 10 and the Internet Explorer / Edge.

    Many things are no longer possible... you have to break new ground.

    Andreas.

    0 comments No comments
  2. Anonymous
    2020-12-04T11:03:19+00:00

    There are some changes you have to make when switching from 32 to 64 bit. You can actually add code to the macro to allow it to work in either environment.

    Here is one of the changes:

    64Bit-****Declaring API functions in 64 bit Office

    https://www.jkp-ads.com/Articles/apideclarations.asp

    With the introduction of Windows 7 and Office 2010 VBA developers face a new challenge: ensuring their applications work on both 32 bit and 64 bit platforms.

    This page is meant to become the first stop for anyone who needs the proper syntax for his API declaration statement in Office VBA.

    It includes links to related MS documentation.

    .

    ! **** Convert 32 bit to 64 bit macrosmake the following changes to your DECLARE statements:

    .

    Private Declare PTRSAFE Function apiOpenClipboard Lib "User32" _

    Alias "OpenClipboard" _

    (ByVal hWnd As LongPtr) _

    As Long

    .

    The way I've done this is to search on DECLARE and then add the PtrSafe keyword after Declare and change the Long to LongPtr (only within the parentheses). This will allow the code to work in either 32 or 64 bit.

    .

    8 people found this answer helpful.
    0 comments No comments
  3. Andreas Killer 144K Reputation points Volunteer Moderator
    2020-12-04T11:07:27+00:00

    There are some changes you have to make when switching from 32 to 64 bit. .

    That is not relevant for this thread, the OP has a 32bit Office on both systems.

    A PTRSAFE declaration and using LongPtr is only necessary on 64bit Office.

    Andreas.

    2 people found this answer helpful.
    0 comments No comments
  4. Anonymous
    2020-12-04T11:13:30+00:00

    Hello, Code is working fine in both laptop. The only thing i face with 64bit windows is the Run Time Error 13 & 91. (Element = Nothing) but once you Wait.Second or Application.Wait after the debugging it go through for few transactions and gettin Debug again.

    1 person found this answer helpful.
    0 comments No comments
  5. Anonymous
    2020-12-04T11:15:02+00:00

    Hi Nothing to do with PtrSafe & LongPtr. I didn't switch the Excel Version from 32bit to 64bit

    0 comments No comments