Now that Office also comes in a 64bit install, where in the registry do you find out if the version of Office installed is 32bit or 64bit?
In my tests many of the approaches described here fail, I think because they rely on entries in the Windows registry that turn out to be not reliably present, depending on Office version, how it was installed etc. So a different approach is to not use the registry at all (Ok, so strictly that makes it not an answer to the question as posed), but instead write a script that:
Here's that approach implemented in VBScript:
Function OfficeBitness()
Dim VBACode, Excel, Wb, Module, Result
VBACode = "Function Is64bit() As Boolean" & vbCrLf & _
"#If Win64 Then" & vbCrLf & _
" Is64bit = True" & vbCrLf & _
"#End If" & vbCrLf & _
"End Function"
On Error Resume Next
Set Excel = CreateObject("Excel.Application")
Excel.Visible = False
Set Wb = Excel.Workbooks.Add
Set Module = Wb.VBProject.VBComponents.Add(1)
Module.CodeModule.AddFromString VBACode
Result = Excel.Run("Is64bit")
Set Module = Nothing
Wb.Saved = True
Wb.Close False
Excel.Quit
Set Excel = Nothing
On Error GoTo 0
If IsEmpty(Result) Then
OfficeBitness = 0 'Alternatively raise an error here?
ElseIf Result = True Then
OfficeBitness = 64
Else
OfficeBitness = 32
End If
End Function
PS. This approach runs more slowly than others here (about 2 seconds on my PC) but it might turn out to be more reliable across different installations and Office versions.
After some months, I've realised there may be a simpler approach, though still one that instantiates an Excel instance. The VBScript is:
Function OfficeBitness()
Dim Excel
Set Excel = CreateObject("Excel.Application")
Excel.Visible = False
If InStr(Excel.OperatingSystem,"64") > 0 Then
OfficeBitness = 64
Else
OfficeBitness = 32
End if
Excel.Quit
Set Excel = Nothing
End Function
This relies on the fact that Application.OperatingSystem, when called from 32-bit Excel on 64-bit Windows returns Windows (32-bit) NT 10.00 or at least it does on my PC. But that's not mentioned in the docs.