Programming for 64-bit vs 32-bit Office 2010
Office 2010 and later bring the option of installing a 64-bit version, which may cause compatibility issues for add-ins written for 32-bit versions of Office.
Here's detailed information from Microsoft about the differences:
Compatibility Between the 32-bit and 64-bit Versions of Office 2010
Office 2010 also gives us a couple of new compiler constants that we can use to determine whether we're running a new version of Office that includes these constants, which "bitness" of Office and, indirectly, which Windows bitness we're running.
The most useful of these constants is Win64. Oddly, it actually tells us which "bitness" of Office we're running in. If Win64 is True, then it's 64-bit Office (which implies 64-bit Windows, since 64-bit Office won't run in 32-bit Windows).
Most people don't believe me when I say this. After all, why would Microsoft call it Win64 instead of Office64 if this were true?
I have no idea. But they did. The code proves it:
Sub WhichVersion() ' The Win64 constant is a misnomer ' It doesn't tell you anything about the "bitness" of Windows ' (well, indirectly it does; more on that anon) ' It DOES tell you the bitness of OFFICE ' ' Run this under Windows 7/8/etc. 64-bit and ' Office 32 and it'll tell you it's NOT Win64. ' #If Win64 Then Debug.Print "It says that this IS Win64" Debug.Print "It really means that this is 64-bit OFFICE." Debug.Print "(And 64-bit Windows, since 64-bit Office requires that.)" #Else Debug.Print "It says it's NOT Win64" Debug.Print "It really means that this IS NOT 64-bit Office." Debug.Print "(It might be 32-bit Office on 64-bit Windows, though.)" #End If ' ' But indirectly, there's this: ' If #Win64 is true, then it IS Windows 64-bit, because: ' - It's Office 64-bit, ' - Which only runs under 64-bit Windows #If VBA7 Then Debug.Print "VBA 7, so it must be Office 2010 or later" #Else Debug.Print "NOT VBA7, so Office 2007 or prior" #End If End Sub
If using an older version of Office, these compiler constants won't be defined, so they'll return False. It's perfectly safe to use them this way.