如何从C#代码访问已安装的Excel Excel加载项方法? [英] How to access an installed excel COM add-ins methods from C# code?

查看:329
本文介绍了如何从C#代码访问已安装的Excel Excel加载项方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的C#excel加载项调用已安装在excel中的COM加载项。它是第三方加载项,因此我无法对代码进行任何更改。



我需要访问加载项中的方法并获取它们返回的值。



我知道在VBA中你可以调用一个COM加载项并使用它的方法,所以有一个C#等价的。



PS我试过使用COM类和COM Wrappers,但它要么不工作,要么我没有正确使用它们。



我尝试过:



我尝试使用DLL来调用方法,但不管我怎么称呼它,它会返回一个异常,说它无法找到xxx.cs类或那个它无法找到切入点。我也尝试过使用invoke方法,但这也不起作用。

I want to call a COM Add-in that is already installed in excel from my C# excel add-in. It is a third party add-in so I can't make any changes to the code.

I need to access the methods in the Add-in and get the value they return.

I know in VBA you can just call a COM Add-in and use it's methods, so is there a C# equivalent of that.

P.S I've tried using COM Classes and COM Wrappers, but it either isn't working or I'm not using them properly.

What I have tried:

I've tried using the DLL to call the methods but whichever way I call it, it returns an exception saying it can't find the xxx.cs class or that it can't find an entry point. I've also tried using an invoke method,but that doesn't work either.

推荐答案

从.NET客户端调用COM组件 [ ^ ]


我建​​议从这里开始:从其他Office解决方案的VSTO加载项中调用代码 [ ^ ] - 从非VBA解决方案访问对象部分。
I'd suggest to start here: Calling Code in VSTO Add-ins from Other Office Solutions[^] - Accessing Objects from Non-VBA Solutions part.


这篇关于如何从C#代码访问已安装的Excel Excel加载项方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆