PoshCode Logo PowerShell Code Repository

Add-ExcelAddins.ps1 by David Valdes 21 months ago
diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1811"></script>download | new post

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.

  1. ###########################################################################"
  2. #
  3. # NAME: Add-ExcelAddins.ps1
  4. #
  5. # AUTHOR: Jan Egil Ring
  6. # EMAIL: jan.egil.ring@powershell.no
  7. #
  8. # COMMENT: This script will check if the specified Microsoft Office Excel Addins are loaded, and if not load them.
  9. #          Tested with PowerShell v2 and Microsoft Office Excel 2007, although it should work fine with PowerShell v1 and older
  10. #         versions of Microsoft Office Excel.
  11. #
  12. # You have a royalty-free right to use, modify, reproduce, and
  13. # distribute this script file in any way you find useful, provided that
  14. # you agree that the creator, owner above has no warranty, obligations,
  15. # or liability for such use.
  16. #
  17. # VERSION HISTORY:
  18. # 1.0 01.11.2009 - Initial release
  19. #
  20. ###########################################################################"
  21.  
  22. $Addinfilename = 'Addin_01.xla'
  23. $Addinfilepath = 'C:\MyAddins\'
  24. $Excel = New-Object -ComObject excel.application
  25. $ExcelWorkbook = $excel.Workbooks.Add()
  26. if (($ExcelWorkbook.Application.AddIns | Where-Object {$_.name -eq $Addinfilename}) -eq $null) {
  27. $ExcelAddin = $ExcelWorkbook.Application.AddIns.Add("$Addinfilepath$Addinfilename", $True)
  28. $ExcelAddin.Installed = "True"
  29. Write-Host "$Addinfilename added"}
  30. else
  31. {Write-Host "$Addinfilename already added"}
  32. $Excel.Quit()

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me