How to activate an addin in Excel 2010 ?

by Giz059 at 2012-11-28 02:11:43

Hi everybody,

I would like a script that load an addin in excel and activate it.

I already have the first part of the script :


$Addinfilename = ‘test.xla’
$Addinfilepath = ‘C:\Temp’
$Excel = New-Object -ComObject excel.application
$ExcelWorkbook = $excel.Workbooks.Add()
if (($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”}
else
{Write-Host “$Addinfilename already added”}
$Excel.Quit()


But this script load the addin but when you look in excel, it is in the “inactive Application Add-ins” and i would like to modify it to have my add-in loaded in the "Active Application Add-ins"

Thanks for your help !
by DonJ at 2012-11-28 08:36:30
No clue on this one - sorry :(. If someone else doesn’t jump in, ask over on StackOverflow.com. More of a developer audience who might have some familiarity with this (you’re technically outside PowerShell with this).

We should find some Excel-COM-guru to answer these questions here - I sure see a lot of 'em, and it just isn’t an area I’m experienced in!
by nohandle at 2012-12-04 06:23:13
Turns out to be easy
enum the addins c and filter them to get the addin object
set its installed property to $true to install it.
$excel.AddIns | foreach {if ($.title -like “euro”) {$.installed=$true}}
Tested on office 2010.
documentation here http://msdn.microsoft.com/en-us/library … =office.14).aspx