/build/static/layout/Breadcrumb_cap_w.png

Trying to run excel xlam add-in to run and load

Hi Guys

I have the following script that I've put together.

I need to load a xlam add-in into the current logged on user. Unfortunately we have both 32 and 64 bit OS machines. So the installation directory that holds the xlam add-in can be in either C:\Program Files\<program> or C:\Program Files (x86)\<program> depending on the os architecture.


The script I have below seems to work on 32bit OS and doesn't load on x64 OS, I can't see any error messages either. Essentially the add-in doesn't load, any help would be greatly appreciated.



$Addinfilename = 'AdvanceOffice.xlam'
$Addinfilepath = 'C:\Program Files\Datastream\Datastream Advance\'
$Addinfilepath64 = 'C:\Program Files (x86)\Datastream\Datastream Advance\'
$Excel = New-Object -ComObject excel.application
$ExcelWorkbook = $excel.Workbooks.Add()
$os_type = (Get-WmiObject -Class Win32_ComputerSystem).SystemType -match '(x86)'

if ($os_type -eq "True") {
        $ExcelWorkbook.Application.AddIns | Where-Object {$_.name -eq $Addinfilename} -eq $null
        $ExcelAddin = $ExcelWorkbook.Application.AddIns.Add("$Addinfilepath$Addinfilename", $True)
        $ExcelAddin.Installed = "True"
        Write-Host "$Addinfilename added"        
        Write-host "32 bit Windows OS"
        Write-Host $os_type
 Else {
    ($os_type -NotLike "True")
    $ExcelWorkbook.Application.AddIns | Where-Object {$_.name -eq $Addinfilename} -eq $null  
    $ExcelAddin = $ExcelWorkbook.Application.AddIns.Add("$Addinfilepathx64$Addinfilename", $True)
    $ExcelAddin.Installed = "True"
    Write-Host "$Addinfilename added"}
    $Excel.Quit()
       
}


0 Comments   [ + ] Show comments

Answers (3)

Posted by: rileyz 9 years ago
Red Belt
1
Just to clarify, you have ensured the addin works for 64-bit Office? I say this because its recommended that ppls used 32-bit Office due to compatibility issues with plugins, ppl that move to 64-bit Office normally want to exceed the 2GB(?) limit in Excel etc - think Powerpivot and all those fancy forecasting stuff that sales and finance use.

*update: you cant debug...
$Addinfilepath64 = 'C:\Program Files (x86)\Datastream\Datastream Advance\'
$ExcelAddin = $ExcelWorkbook.Application.AddIns.Add("$Addinfilepathx64$Addinfilename", $True)

Missing the x ...

Also you're missing a terminating curly bracket at the Write-Host $os_type at the first IF block ...

Posted by: djjass 9 years ago
Senior Purple Belt
0
The add-in only runs on 32 bit office. The application is 32bit, but the location of where the add-in is located will change depending on the os architecture, eg. Program Files or Program Files (x86).

All i'm trying to do is determine the os architecture for the machine and load the corresponding add-in based on the location of where it lives.

Comments:
  • Ah! I cant read, lol. - rileyz 9 years ago
    • Read my updated post. - rileyz 9 years ago
Posted by: anonymous_9363 9 years ago
Red Belt
0
Surely a 32-bit app should be installed in the 32-bit file location, irrespective of the host OS's bitness?

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ