我有一个VB6/VBA应用程序,它连接到Excel并加载工作簿。多年来一直表现良好。我们现在升级到Excel 2010,遇到了一些问题。经过故障排除,似乎如果关闭PowerPivot COM Add-In,则该进程能够像以前一样运行而没有任何问题。虽然我正在寻找确切的原因,但我想看看是否可以仅针对我的应用程序关闭该Add-In。我这样加载Excel:
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
在一个测试的Excel工作簿中,我有这段代码来列出插件。但是只有“Excel插件”才会被列出来。而“COM插件”则不会被列出。
Sub ListAddIns()
Dim CurrAddin As Excel.AddIn
Dim r As Long
Dim ws As Excel.Worksheet
Set ws = ActiveSheet
Cells.Select
Selection.ClearContents
Range("A1").Select
r = 1
For Each CurrAddin In Excel.Application.AddIns
ws.Cells(r, 1).Value = CurrAddin.FullName
ws.Cells(r, 2).Value = CurrAddin.Installed
ws.Cells(r, 3).Value = CurrAddin.Name
ws.Cells(r, 4).Value = CurrAddin.Path
ws.Cells(r, 5).Value = CurrAddin.progID
ws.Cells(r, 6).Value = CurrAddin.CLSID
r = r + 1
Next CurrAddin
MsgBox "Its done.", vbInformation
End Sub
在找到引用所需的COM Add-In之后,我需要防止它在我的应用程序中加载Excel对象。欢迎任何帮助或建议。
谢谢。