Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

.net

excel

vba

com

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..
like image 815
chopikadze Avatar asked Jan 19 '26 23:01

chopikadze


1 Answers

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.

like image 81
chopikadze Avatar answered Jan 22 '26 11:01

chopikadze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!