How to tell if I am dealing with Excel 32-bit or 64-bit?

ransomedbyfire

Board Regular
Joined
Mar 9, 2011
Messages
121
I am using someone else's virtual machine with Excel 2010 to test a code to see if it will work on 64-bit versions of Excel. But I am not 100% sure that the test machine is running in 64-bit mode. Is there a code I can use, or somewhere I can look, to verify that the test machine is simulating 64-bit Excel?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Have you read the text I linked to?

In any case... here at work (Excel 2003 on Win XP), VBA7 returns false (actually it returns nothing, but with CBool that becomes False). I can test at home tonight for the 64-bit version what result I get there...
 
Upvote 0
It's the #Win64 constant that tells you if office is 64bit. #VBA7 only tells you it's Office 2010.
 
Upvote 0
I thought the WIN64 constant only tells if your Windows is 64-bit, which can still have a 32-bit Office (2010)...

Edit: pasted from my link:
As stated earlier, there are two new conditional compilation constants: VBA7 and Win64. To ensure backward compatibility with previous versions of Microsoft Office, you use the VBA7 constant (this is the more typical case) to prevent 64-bit code from being used in the earlier version of Microsoft Office. For code that is different between the 32-bit version and the 64-bit version, such as calling a math API which uses LongLong for its 64-bit version and Long for its 32-bit version, you use the Win64 constant. The following code demonstrates the use of these two constants.
To summarize, if you write 64-bit code and intend to use it in previous versions of Microsoft Office, you will want to use the VBA7 conditional compilation constant. However, if you write 32-bit code in Office 2010, that code works as is in previous versions of Microsoft Office without the need for the compilation constant. If you want to ensure that you are using 32-bit statements for 32-bit versions and 64-bit statements for 64-bit versions, your best option is to use the Win64 conditional compilation constant.

I interpret that as: VBA7 indicates if your Office is 64-bit
 
Last edited:
Upvote 0
Nope:
"For code that is different between the 32-bit version and the 64-bit version, ..., you use the Win64 constant."

You can use #VBA7 to prevent 64bit code in earlier versions (since no version pre 2010 had a 64bit option). In 32bit 2010, you can still use the LongPtr and PtrSafe statements, but they would fail in earlier versions, so you can use #VBA7 to get round that.

More clearly, from the 'Introducing the VBA7 code base' section of the article:
"The VBA7 constant helps ensure the backward compatibility of your code by testing whether your application is using VBA 7 or the previous version of VBA. The Win64 constant is used to test whether code is running as 32-bit or as 64-bit"
 
Upvote 0
hmm... still confusing to me...
Imho, it makes no sense to call a constant WIN64 if it indicates if Office is 64-bit or not... more logically named constant would be OFFICE64...
I do follow your explanation for VBA7, but I have trouble wrapping my head around the WIN64 :confused:

They should have made it like this:
WIN64: is your Windows 64-bit?
OFFICE64: is your Office 64-bit?
VBA: indicating Office/VBA version
WIN: indicating Windows version
 
Upvote 0
I didn't say it made sense, just that that's how it is! (from a VBA perspective, we don't generally care if windows is 64bit).
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,813
Members
452,945
Latest member
Bib195

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top