使用标准.NET库使用VBA [英] Using standard .Net libraries with VBA

查看:167
本文介绍了使用标准.NET库使用VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功已经能够运行我自己的.NET code按照张贴在这里的步骤的从Office 2003 执行.NET 3.0 code

I have successfully been able to run my own .Net code by following the steps posted here Execute .NET 3.0 code from Office 2003

有没有办法使用标准的.NET库,而无需编写一个包装?这样,我们就能避免无需注册和客户端的计算机上安装一个自定义的DLL到GAC。

Is there a way to use the standard .Net libraries without having to write a wrapper? This way we can avoid having to register and install a custom DLL into the GAC on the client's machine.

我发现TLB文件已在C:\ WINDOWS \ Microsof.NET \框架文件夹,并且已经能够添加引用mscorlib.dll中。看着对文件<一个href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged.aspx">RijndaelManaged,这个类看起来是COM可见。

I've found tlb files already in the C:\Windows\Microsof.NET\Framework folders, and have been able to add a reference to mscorlib.dll. Looking at the documentation for RijndaelManaged, this class appears to be COM visible.

我可以创建一个实例,但只要我努力工作有了它,我得到的错误(如类型不匹配)。

I am able to create an instance, but as soon as I try and work with it, I get errors (e.g. "Type mismatch").

Sub Macro1()
   Dim aesImplementation As New RijndaelManaged

   Set key = aesImplementation.GenerateKey()
   Set iv = aesImplementation.GenerateIV()
End Sub

我愿意接受你所提供的任何黑客!

I am willing to accept any hacks you have to offer!

推荐答案

还没有可能的。 VBA(Visual C ++应用程序)不是VB,而是一个独立的交易模仿所有的基本语法旧版本的VB。这几乎就像使用常规,旧的VB一个非常精简版。事实上,VBScript是最匹配的VBA。也许有一天,微软将建立的方法直接与海关总署合作,但在那之前(那日子就可能意味着COM的死我敢肯定),则使用COM 的CreateObject是滞留() 方法,添加引用COM库登记您的Office项目,或直接引用在Office项目中的VBA / COM兼容的DLL或TLB文件。

Not yet possible. VBA (VB for Applications) is not VB, but rather a separate deal mimicking all the basic syntax as older versions of VB. It's almost like using a very stripped down version of regular, older VB. In fact, VBScript is the closest match to VBA. Perhaps someday, Microsoft will build in methods to work directly with the GAC, but until then (and that day will likely mean the death of COM I'm sure), you're stuck using COM CreateObject() method, adding a reference to a COM registered library to your Office project, or directly referencing a VBA/COM compatible DLL or TLB file in your Office project.

有默认GAC不少支持COM的库,但对于大多数,你被卡住创建一个COM可调用包装首先在VB.Net或C#。

There are quite a few COM-enabled libraries in the default GAC, but for the majority, you are stuck creating a Com Callable Wrapper first in VB.Net or C#.

相反,pretty的多所有的MS Office应用程序是COM调用,这样你就可以安装Office工作,通过VB.Net项目,应用服务,你希望所有。

Conversely, pretty much all MS Office apps are COM callable, so you can work with installed Office apps through VB.Net projects all you want.

这篇关于使用标准.NET库使用VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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