gpt4 book ai didi

vba - Excel VBA检查插件是否已安装但未打开

转载 作者:行者123 更新时间:2023-12-04 20:05:55 25 4
gpt4 key购买 nike

在从当前上下文调用该插件中的脚本之前,我有以下代码来检查所需的插件是否已安装/可用:

Function IsAddinEnabled(addinName as string) As Boolean
IsAddinEnabled = True
Dim myAddin As addin
On Error GoTo NotExists
Set myAddin = Application.AddIns2(addinName)
If myAddin.IsOpen = False Then ' this logic is my workaround
myAddin.Installed = False 'uninstall
myAddin.Installed = True ' install to "Open" the addin
Else
myAddin.Installed = True 'redundant
End If
Exit Function
NotExists:
IsAddinEnabled = False
End Function

问题出现在:
myAddin.IsOpen = false我必须添加这个逻辑来重新安装插件。卸载并重新安装插件有点麻烦/减慢速度。有没有办法在不重新安装插件的情况下强制插件“打开”?

最佳答案

每@Charles Williams

这是我使用的方法:

Function IsAddinEnabled(addinName as string) As Boolean
IsAddinEnabled = True
Dim myAddin As addin
On Error GoTo NotExists
Set myAddin = Application.AddIns2(addinName)
If myAddin.IsOpen = False Then ' this logic is my workaround
Workbooks.Open myAddin.Path & "\" & myAddin.Name 'open the addin, if it's not open
Else
myAddin.Installed = True 'redundant
End If
Exit Function
NotExists:
IsAddinEnabled = False
End Function

关于vba - Excel VBA检查插件是否已安装但未打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39413928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com