Converting Excel 32-Bit App to Excel 64-Bit App

richlocus
2StarLounger
Posts: 156
Joined: 03 Oct 2015, 00:30

Converting Excel 32-Bit App to Excel 64-Bit App

Post by richlocus »

Hello:

I currently have an application developed on 32-bit Excel. I ran it on a 64-bit platform, and even recompiled it, but it seems like it didn't change the code to 64-bit because I was able to run the version I compiled on the 64-bit platform on my 32-bit Excel platform.

How does that work? If I did want to change the code to 64-bit, would I have to first change it to a xlsx file to strip the code, then put the xlsx version on the 64-bit machine, then copy and past the code to the 64-bit Excel (after I changed it to an xlsm on the 64-bit machine) and then compile it?

Thanks,
Rich Locus

User avatar
HansV
Administrator
Posts: 78471
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Converting Excel 32-Bit App to Excel 64-Bit App

Post by HansV »

Almost all VBA code can be written in such a way that it will run on both 32-bit and 64-bit Excel...
Keep in mind that "compiling" in the Visual Basic Editor does not generate pure machine code, but generates tokenized code instead. The VB interpreter will then run the tokens, regardless of the bitness.
Best wishes,
Hans

richlocus
2StarLounger
Posts: 156
Joined: 03 Oct 2015, 00:30

Re: Converting Excel 32-Bit App to Excel 64-Bit App

Post by richlocus »

Thanks Hans! That finally clears up the mystery. You have spoken about the token, which I wasn't aware :)
Regards,
Rich Locus

User avatar
Jay Freedman
Microsoft MVP
Posts: 1318
Joined: 24 May 2013, 15:33
Location: Warminster, PA

Re: Converting Excel 32-Bit App to Excel 64-Bit App

Post by Jay Freedman »

Since your code runs without errors in both 32-bit and 64-bit Excel, it's clear that you aren't using any functions from the Windows API. If you do want to use those functions in future apps, you'll need this excellent resource to find the proper declarations for them and methods for making the app compatible with both bitnesses:
https://jkp-ads.com/Articles/apideclarations.asp

richlocus
2StarLounger
Posts: 156
Joined: 03 Oct 2015, 00:30

Re: Converting Excel 32-Bit App to Excel 64-Bit App

Post by richlocus »

Thank you Jay! Very helpful!!