添加安装并引用 [英] Add in installed and referenced

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

问题描述

我想检查是否安装了插件并引用。以下代码检查添加是否已安装。如何检查是否在excel中引用。

I want to check if addin is installed and is referenced. The below code checks for add in is installed or not. How can i check if its referenced in excel.

引用我的意思是工具> Addins> Addins Dailog框>如果安装了加载项>检查是否具有特定名称的加载项被检查。

By Refernced i mean is Tools > Addins > Addins Dailog box > If addins is installed > check if a addin with particular name is checked.

我最好没有任何循环。

Sub Demo() 
    Dim b As Boolean 
    b = CheckAddin("Solver add-in") 
    MsgBox "Solver is " & IIf(b, "", "not ") & "installed" 
End Sub 

Function CheckAddin(s As String) As Boolean 
    Dim x As Variant 
    On Error Resume Next 
    x = AddIns(s).Installed 
    On Error Goto 0 
    If IsEmpty(x) Then 
        CheckAddin = False 
    Else 
        CheckAddin = True 
    End If 
End Function 


推荐答案

Sub Sample()
    Dim wbAddin As Workbook

    On Error Resume Next
    Set wbAddin = Workbooks(AddIns("My Addin").Name)

    If Err.Number <> 0 Then
        On Error GoTo 0
        'Set wbAddin = Workbooks.Open(AddIns("My Addin").FullName)
        Debug.Print "Not Referenced"
    Else
        Debug.Print "Referenced"
    End If
End Sub

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

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