siva
siva

Reputation: 377

Detect whether MS Office installed is 32bit or 64bit by using registry

I want to install vsto addin based on the excel version (32 bit or 64 bit). I am planning to bundle both 32bit and 64 bit msis and install one by determining the excel version. I am able to find this link to detect whether 2010 office is 32 bit or 64 bit by using registry. Detect whether Office is 32bit or 64bit via the registry But i want to check for excel 2007 and 2013 whether they are 32 bit or 64 bit. Is it possible to detect them via registry.

Upvotes: 5

Views: 9311

Answers (5)

MattP
MattP

Reputation: 1

I'm determining office bitness by trying to get at an office type library through createobject, if it fails then I don't have Office installed with the same bits as the host O/S. Works a treat.

Upvotes: 0

Joe Healy
Joe Healy

Reputation: 5817

Given: Office32 is installed into "Program Files (x86)", this works for me.

I basically check to see if winword.exe is somewhere below the key. If they don't install the word part, well, tough at this point. I use this to variably run 32-bit or 64-bit msi installers for office.

<Fragment>
<Property Id="IS_32BITOFFICE">
  <DirectorySearch Path="[ProgramFilesFolder]\Microsoft Office"                  
                   Depth="4"                   
                   AssignToProperty="no"                   
                   Id="IS_32BIT_OFFICE_DIRSEARCH">
    <FileSearch   Name="winword.exe" />
  </DirectorySearch>
</Property>

<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
  <Component Id="WIN64_OFFICE32_MSI">
    <File Id="WIN64_OFFICE32_MSI" src="WIN64_OFFICE32.txt"/>
    <Condition>IS_32BITOFFICE</Condition>
  </Component> 
  <Component Id="WIN64_OFFICE64_MSI">
    <File Id="WIN64_OFFICE64_MSI" src="WIN64_OFFICE64.txt"/>
    <Condition>NOT IS_32BITOFFICE</Condition>
  </Component> 
    </ComponentGroup>
</Fragment>

Upvotes: 4

Eric Legault
Eric Legault

Reputation: 5834

First, look for the installed version of Outlook in this key:

HKEY_CLASSES_ROOT\Outlook.Application\CurVer

The value will be Outlook.Application.15 (for 2013). Then parse that value to get the integer and lookup this key:

HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office\15.0\Outlook

If it exists, check the value of Bitness to determine if it is 32-bit (x86) or 64-bit (x64). If it doesn't exist, assume 32-bit.

Upvotes: 7

Sarvesh Mishra
Sarvesh Mishra

Reputation: 2072

You can't reliably detect it from registry (direct call). Better is to create Custom installer module in C# or VB.net, fetch ProductCode of application. From product code, you can get the Bitness.

Product code is also fetched from registry, but let Office application handle it.

Private IsExcel32Bit As Boolean = False
Private IsExcel64Bit As Boolean = False
Private ReadOnly STR_prdCodeDelimeter As Char = CChar("-")

Private Sub GetExcelBitness(ByVal exApp As Microsoft.Office.Interop.Excel.Application)
    Dim prdCode As String = exApp.ProductCode
    If Not String.IsNullOrEmpty(prdCode) AndAlso CInt(prdCode.Split(STR_prdCodeDelimeter)(3)(0).ToString) = 0 Then
        IsExcel32Bit = True
    ElseIf Not String.IsNullOrEmpty(prdCode) AndAlso CInt(prdCode.Split(STR_prdCodeDelimeter)(3)(0).ToString) = 1 Then
        IsExcel64Bit = True
    End If
End Sub

Btw keeping both installer separately is going to help you in future. Sometimes product code might be null or wrong if MS Office is not installed properly.

Upvotes: 3

Eugene Astafiev
Eugene Astafiev

Reputation: 49395

You can use the product code (GUID) to identify the bitness of Office applications. See How to detect whether installed MS Office 2010 is 32 or 64 bit for more information.

Upvotes: 2

Related Questions