我有一个excel加载项,无法在Application.AddIns
中找到。我通过转到文件 - >手动打开加载项。打开 - >浏览到addin.xlam
。是否需要以编程方式添加加载项才能显示在Application.AddIns
?
修改
@Fadi
我在其中任何一个打印功能中都没有看到我的插件。在第一个,它只打印我当前工作簿的名称,这就是全部。第二个成功打印出我已编程添加的其他10个加载项,但不是手动添加的加载项。
Sub MsgWorkbooks()
Dim s As String
For Each wb In Workbooks
s = s + app.Name
Next wb
MsgBox s
End Sub
Sub MsgAddIns()
Dim s As String
For Each app In Application.AddIns
s = s + app.Name
Next app
MsgBox s
End Sub
答案 0 :(得分:1)
也许您需要安装它:
Sub InstallAddIn()
Dim AI As Excel.AddIn
Set AI = Application.AddIns.Add(Filename:="d:\addin.xlam") 'change the addin fullname
AI.Installed = True
End Sub
更多信息here
正如Doug Glancy评论我们可以检查插件是否像任何普通工作簿一样可用。所以我们可以使用这个功能:
Function IsAddinLoaded(adName As String) As Boolean
Dim addinWB As Workbook
On Error Resume Next
Set addinWB = Workbooks(adName)
If Err = 0 Then IsAddinLoaded = True
On Error GoTo 0
End Function
测试:
Sub Test()
if IsAddinLoaded("addin.xlam") = true Then ' change the name of addin
msgbox "Addin is loaded"
Else
msgbox "Addin not loaded"
End if
End Sub