如何在Excel VBA中使用.NET对象? [英] How can I make use of .NET objects from within Excel VBA?

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

问题描述

VBA代码可以实例化并使用.NET对象吗?我感兴趣的特定类是System.IO.Compression.GZipStream。



对于信息 GAC是.NET全局程序集缓存

解决方案

我认为安迪确定了这个答案,但我不确定CLR加载规则的方面是完全正确的。



保存作为GZipStream包装器的类的.NET程序集将暴露给COM,并像任何其他COM项目库和类一样注册。在这方面,VBA将通过注册表找到COM暴露的.NET程序集的位置。将程序集放在GAC中可能很聪明,因此它不能移动(因为移动程序集会使注册表信息无效),但只要注册表指向正确的位置,它应该是正常的。 p>

关于这个主题的一个好的初学者教程是 here



希望这有帮助。 ..


Can VBA code instantiate and use .NET objects? The specific class I'm interested in is System.IO.Compression.GZipStream.

For Info GAC is the .NET Global Assembly Cache

解决方案

I think Andy nailed this answer, but I'm not certain that the aspect regarding the CLR loading rules is exactly right.

The .NET Assembly that holds the class acting as the wrapper for GZipStream would be exposed to COM and registered just like any other COM project library and class. In this regard, VBA would find the location of the COM-exposed .NET assembly via the registry. It might be smart to put the assembly in the GAC, so that it can't move (since moving the assembly would invalidate the registry info), but so long as the registry points to the right place, it should be fine.

A good beginner's tutorial on the subject is here

Hope this helps...

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

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