如果没有安装AddIns,则无法访问Excel的Application.ComAddIns属性

时间:2021-10-26 22:38:00

This code snipped for the Windows Scripting Host displays the number of COM-AddIns currently installed into Excel.

针对Windows Scripting Host剪辑的此代码显示当前安装到Excel中的COM-AddIns的数量。

It works fine except for when there are no COM-AddIns installed. I believe it should output a "0", but instead it raises an exception (code 800A03EC). Does anyone know why?

除了没有安装COM-AddIns之外,它工作正常。我相信它应该输出一个“0”,但它会引发异常(代码800A03EC)。有谁知道为什么?

test.vbs

Set objExcel = CreateObject("Excel.Application")
WScript.Echo objExcel.ComAddIns.Count

1 个解决方案

#1


Looks like a bug in Excel. You'll probably have to abuse VB's error handling to work around it.

看起来像Excel中的错误。你可能不得不滥用VB的错误处理来解决它。

On Error Resume Next
WScript.Echo objExcel.ComAddIns.Count
If Err And Err.Number = 1004 Then
    WScript.Echo "No add-ins"
End If
On Error GoTo 0

#1


Looks like a bug in Excel. You'll probably have to abuse VB's error handling to work around it.

看起来像Excel中的错误。你可能不得不滥用VB的错误处理来解决它。

On Error Resume Next
WScript.Echo objExcel.ComAddIns.Count
If Err And Err.Number = 1004 Then
    WScript.Echo "No add-ins"
End If
On Error GoTo 0