加载 Excel 加载项 [英] Load Excel add-in

查看:39
本文介绍了加载 Excel 加载项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过了:

$sAddIn = "H:progessxleqd.xla"
$oExcel = ObjCreate("Excel.Application")
$oExcel.Visible = 1
$oExcel.WorkBooks.Add
$oAddIn = $oExcel.AddIns.Add($sAddIn)
$oAddIn.Installed = True
$oExcel.WorkBooks.Open("H:Balance_Inquiry.xls")

当我这样做时:

Run('"c:pathtoexcelexcel.exe" "c:pathtoaddinaddin.xla"')

它会起作用.但我更喜欢前一种解决方案,因为我需要两个不同的加载项.

It will work. But I prefer the former solution because I need two different add-ins.

$sAddIn = "H:progessxleqd.xla"
$oExcel = ObjCreate("Excel.Application")
$oExcel.Visible = 1
$oExcel.WorkBooks.Add
$oAddIn = $oExcel.AddIns.Add($sAddIn)
$oAddIn.Installed = False
$oAddIn.Installed = True
$oExcel.WorkBooks.Open("H:Balance_Inquiry.xls")

这似乎可以解决问题.第一次安装并工作.后来就没有了.即使安装了它,它也不会第二次执行.也许有人可以解释或提供更优雅的解决方案?

This seems to do the trick. First time it got installed and worked. Afterwards it didn't. Even when it is installed it doesn't execute the second time. Maybe someone can explain or provide a more elegant solution?

推荐答案

确实是个奇怪的问题.似乎插件只会在您安装时执行其操作?这不是 Excel 插件的行为方式,这就是您在尝试自动化时看到奇怪行为的原因.

Strange problem indeed. It seems that the addon will only do its operations when you install it? That is not how Excel addons should behave, and that is why you are seeing strange behavior when trying to automate it.

如果需要重新安装插件才能工作,那么确实唯一的解决方案是重新安装插件.

If the addon needs to be reinstalled to work, then indeed the only solution is to reinstall the addon.

$oAddIn.Installed = False
$oAddIn.Installed = True

如果这是由您或您自己企业中的某个人编写的插件,那么您可能需要确定插件本身的问题.我可以放心地向您保证,正常的操作模式运行良好.:))

If this is an addon that is written by you or someone in your own business, then you might want to identify the problem in the addon itself. I can safely assure you that the normal mode of operation works well. :))

作为额外提示,您可能想要这样做:

As a bonus tip, you might want to do this:

$oAddIn = $oExcel.AddIns.Add($sAddIn, True)

如果有必要,它会将文件复制到适当的位置,否则它会被留下.

It will copy the file to the appropriate location if that is necessary, otherwise it is left alone.

这篇关于加载 Excel 加载项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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