VBA and “Class doesn't support Automation or does not support expected interface”

佐手、 提交于 2019-12-10 17:53:19

问题


I have .NET assembly with ComVisible class. Some days ago (I can find that moment exactly, by git) something happened - Excel doesn't see anymore this class. So:

I have interface

[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface MyInterface { ... }

and class

[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[ProgId("MyClass.Id")]
public class MyClass { ... }

Excel creates the instance by

Dim c as MyClass
Set c = New MyClass

Earlier everything worked like a charm, but after deleting some methods (from interface and class) Excel is crazy - it shows me an error Class doesn't support Automation or does not support expected interface. Where can be a problem?

  • I checked everything some times. Error occurs exactly after deleting some methods
  • This class is partial (maybe the problem is somewhere here?)
  • Earlier everything worked..

回答1:


Damn three times. For the future guys: after removing methods/properties from your COM-library you should re-add reference to .tlb file in your Excel's file.



来源:https://stackoverflow.com/questions/8817215/vba-and-class-doesnt-support-automation-or-does-not-support-expected-interface

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!