在此PowerShell脚本中添加1个以上的Excel Addin [英] Adding more than 1 Excel Addin into this PowerShell Script

查看:153
本文介绍了在此PowerShell脚本中添加1个以上的Excel Addin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hiya,

我正在使用http://poshcode.org/1811中的这个脚本,它添加了Excel Addin但是我需要修改它以便添加一个第二个加载项,如果可能,但我是一个新手PowerShell用户,虽然我尝试了几种方法,但我无法让它工作。

I am using this script from http://poshcode.org/1811 which adds in an Excel Addin however I need to modify it so it adds a second add-in if possible but I'm a novice PowerShell user and although I've tried a few ways, I can't get it to work.

这个脚本由Jan提供Egil Ring

This the script courtesy of Jan Egil Ring

任何帮助表示感谢谢谢

###################### ################################################## ###"
$


#NAME:Add-ExcelAddins.ps1



#作者: Jan Egil Ring

#EMAIL:jan.egil.ring@powershell.no


$
#COMMENT:此脚本将检查是否指定加载了Microsoft Office Excel Addins,如果没有加载它们。

#         使用PowerShell v2和Microsoft Office Excel 2007进行测试,虽然它适用于PowerShell v1及更早版本但
#      Microsoft Office Excel的版本。


$
#您拥有免版税的使用权,修改权,复制权,以及b $ b#分发此权限脚本文件以您认为有用的任何方式提供,只要您认为上述创建者,上述所有者没有保证,义务,b
#或此类使用的责任。


$
#版本历史记录:

#1.0 01.11.2009 - 初始版本



################################################ ############################"
$


$ 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&q uot;
$
写主机"$ addinfilename added"}}
else

{Write-Host" $ Addinfilename already added"}

$ Excel.Quit()

###########################################################################"
#
# 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()

推荐答案

使用新的加载项重复练习:

Just repeat the exercise with the new add-in:

 


ExcelWorkbook.Application.AddIns.Add('c:\ temp \ mysecondaddin.xla' ',
ExcelWorkbook.Application.AddIns.Add('c:\temp\mysecondaddin.xla'',


True)

这就是你所需要的。 其余大部分代码都是愚蠢的或用于演示目的。 要发出此信息,您需要学习PowerShell和Excel。

That is all you need.  Most of the rest of the code is just silly or for demo purposes.  To issue this you will need to learn PowerShell and Excel.


这篇关于在此PowerShell脚本中添加1个以上的Excel Addin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆