本文介绍了Excel VBA检查是否安装了Addin但未打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <$ c 

我有以下代码来检查在当前上下文中的Addin内调用脚本之前是否安装/可用的插件: $ c>函数IsAddinEnabled(addinName as string)As Boolean
IsAddinEnabled = True
Dim myAddin As addin
错误GoTo NotExists
设置myAddin = Application.AddIns2(addinName)
如果myAddin.IsOpen = False然后'这个逻辑是我的解决方法
myAddin.Installed = False'卸载
myAddin.Installed = True'安装到打开加载
Else
myAddin.Installed = True'冗余
结束If
退出函数
NotExists:
IsAddinEnabled = False
结束函数

问题出现在:



myAddin.IsOpen = false 我不得不添加这个逻辑来重新安装加载项。这是一个轻微的滋扰/减慢卸载并重新安装插件。有没有办法强制和Addin打开而不重新安装加载项?

解决方案

Per @Charles Williams

这是我使用的方法:

 函数IsAddinEnabled(addinName as string)As Boolean 
IsAddinEnabled = True
Dim myAddin As addin
错误GoTo NotExists
设置myAddin = Application.AddIns2(addinName)
如果myAddin.IsOpen = False然后'这个逻辑是我的解决方法
Workbooks.Open myAddin.Path& \& myAddin.Name'打开加载项,如果它不是打开
Else
myAddin.Installed = True'冗余
如果
退出函数
NotExists:
IsAddinEnabled = False
结束函数


I have the following code to check if a required addin is installed/available before calling scripts within that Addin from the current context:

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

The problem arises when:

myAddin.IsOpen = false I had to add this logic to reinstall the addin. It's a slight nuisance/slow down to uninstall and reinstall the addin. Is there a way to force and Addin to "open" without re-installing the addin?

解决方案

Per @Charles Williams

This is the method I've used:

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

这篇关于Excel VBA检查是否安装了Addin但未打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 21:32