试图调用从VBA一个.NET函数 - 在VBA中使用RUN [英] Trying to call a .NET function from VBA - using RUN in VBA

查看:323
本文介绍了试图调用从VBA一个.NET函数 - 在VBA中使用RUN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET类库,并做了必要将其包含在Excel中的所有东西。 (expoting作为COM可见,对于COM-互操作和regasm'ing该dll以及) 我用Excel 2007中以Excel加载项,我看到我的'TestLib.Functions为选中。我能够访问该功能在我的VBA code为:

I have a .Net class library and have done all things needed to include it in excel. (expoting as COM visible, for com-interop and regasm'ing the dll as well) I use excel 2007. In the excel addins, I see my 'TestLib.Functions' as checked. I am able to access the function in my VBA code as :

Set lib = New TestLib.Functions
returnVal = lib.Add(5);

这工作得很好。

有关其他code审查的原因,我也看到了从另一个库中的某些功能访问使用Run方法如下:

For other code review reasons, I also saw some functions from another library accessed using the RUN method as :

Run("avSomeFunction", paramvalue)

现在,在VBA编辑器,如果我尝试访问添加功能,以同样的方式,

Now, in the VBA editor, if I try to access the 'Add' function in the same way,

Run("Add", 5)

我得到一个错误说无法找到名称添加的宏。难道neccesary,我应该 再次在VB editot-工具引用再从做Regasm的.NET DLL添加TLB作为参考,与众不同?可有人请让我知道了什么​​是这里的问题。

I get an error saying 'Cannot find a macro with name Add'. Is it neccesary that I should add tlb as a reference once again in the VB editot-tools-references again, apart from doing Regasm for the .net dll? Can someone please let me know what is the problem here.

PS:对于一些很疯狂的原因,我只是有这个工作,一旦突然,但再次失败后在那里工作。很奇怪:(

p.s : for some very crazy reason, I just had this working once suddenly but again failed to work there after. very weird:(

推荐答案

之间区别:添加一个TLB作为参考来调用函数VS使用'运行'?有这个问题的答案。基本上,我缺少了参考的VBA项目的TLB。除了登记的DLL中,TLB也需要添加作为参考。

Difference between : adding a tlb as reference to invoke function VS using 'Run'? has the answer to this. Basically, I was missing the reference to the tlb in the VBA project. Apart from registering the dll, the tlb also needs to be added as a reference.

这篇关于试图调用从VBA一个.NET函数 - 在VBA中使用RUN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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