PoshCode Archive  Artifact [e54f8969d1]

Artifact e54f8969d1ae319c791780a04a978aa545f95c6b921437e7a3d0a0a0eea47073:

  • File Add-ExcelAddins.ps1 — part of check-in [7a2b2421c8] at 2018-06-10 14:21:14 on branch trunk — This script will check if the specified Microsoft Office Excel Addins are loaded, and if not load them. (user: David Valdes size: 1847)

# encoding: ascii
# api: powershell
# title: Add-ExcelAddins.ps1
# description: This script will check if the specified Microsoft Office Excel Addins are loaded, and if not load them.
# version: 1.0
# type: script
# author: David Valdes
# license: CC0
# x-poshcode-id: 6816
# x-archived: 2017-03-25T17:19:03
# x-published: 2017-03-23T02:59:00
#
# Tested with PowerShell v2 and Microsoft Office Excel 2007, although it should work fine with PowerShell v1 and older versions of Microsoft Office Excel.
#
###########################################################################"
#
# NAME: Add-ExcelAddins.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jan.egil.ring@powershell.no
#
# COMMENT: This script will check if the specified Microsoft Office Excel Addins are loaded, and if not load them.
#          Tested with PowerShell v2 and Microsoft Office Excel 2007, although it should work fine with PowerShell v1 and older
#	  versions of Microsoft Office Excel.
#
# You have a royalty-free right to use, modify, reproduce, and
# distribute this script file in any way you find useful, provided that
# you agree that the creator, owner above has no warranty, obligations,
# or liability for such use.
#
# VERSION HISTORY:
# 1.0 01.11.2009 - Initial release
#
###########################################################################"

$Addinfilename = 'Addin_01.xla'
$Addinfilepath = 'C:\MyAddins\'
$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()