在 VBA 中使用 System.Collections.ArrayList - 需要什么 .NET Framework 版本? [英] Use System.Collections.ArrayList in VBA - what .NET Framework version is needed?

查看:116
本文介绍了在 VBA 中使用 System.Collections.ArrayList - 需要什么 .NET Framework 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Excel 的 VBA 脚本中使用 System.Collections.ArrayList.现在我想知道:为此需要哪个 .NET Framework 版本?

I want to use System.Collections.ArrayList in my VBA script in Excel. Now I'm wondering: which .NET Framework version is required for that?

我问的原因:在这个网站上,它解释了它的用法类和关于可能的错误消息,它强烈声明(我强调):

The reason I'm asking: on this site it explains the usage of that class and regarding a possible error message it strongly states (emphasis by me):

这是由于没有安装正确的 .Net Framework 版本造成的.正确的版本是 3.5.没关系如果你有像 4.7 这样的更高版本,你必须安装 3.5.

This is caused by not having the correct .Net Framework version installed. The correct version is 3.5. It doesn’t matter if you have a later version like 4.7, you must have 3.5 installed.

与此相反,微软官方 ArrayList 的文档在适用于"下清楚地列出了相当多的 .NET Framework 版本.

In contrary to that, Microsoft's offical documentation for ArrayList clearly lists quite a lot of .NET Framework versions under "Applies to".

现在,我显然想信任官方文档而不是单个网页:尽管我在谷歌上搜索过,但我还没有找到其他网站确认该限制.但也许只是 3.5 是唯一允许在 VBA 中使用该类的版本.

Now, I clearly want to trust offical documentation more than a single webpage: as much as I googled, I haven't found another site confirming that restriction. But maybe it's just that 3.5 is the only version allowing the usage of that class in VBA.

所以,请谁能告诉我如何确定我是否可以使用 ArrayList(或任何其他 .NET 类,如果可以进行概括)与所有文档中列出的版本 - 还是真的只是 v3.5?

So, please, can anyone tell me how to find out if I can use the ArrayList (or any other .NET class for that matter, if a generalization could be made) with all of the versions listed in the docs — or is it really just v3.5?

哦,以防万一这是相关的:我知道并使用后期绑定来避免您可以添加到 Excel 工作簿的引用,以避免版本特定引用的问题.

Oh, and just in case that this is relevant: I know about and use late binding to avoid the references that you could add to an Excel workbook, to avoid problems with the version specific references.

Dim arrLst As Object
Set arrLst = CreateObject("System.Collections.ArrayList")

推荐答案

正如评论中所说,我没有安装并运行 .Net Framework 3.5

As said in the comments I did not have .Net Framework 3.5 installed and running

Dim arrLst As Object
Set arrLst = CreateObject("System.Collections.ArrayList")

给出了一个自动化错误.我安装了 .Framework 3.5,自动化错误消失了.

gave an automation error. I installed .Framework 3.5 and the automation error disappeared.

对于 .Net Framework 的安装,我遵循了此 文档 但您需要在 PC 上拥有管理员权限.

For the installation of .Net Framework I followed the steps outlined in this documentation but you need admin rights on the PC.

有关已安装的 .Net Framework 版本的信息,我使用了thisPowerShell 脚本

For getting information on the installed .Net Framework version I used this powershell script

这篇关于在 VBA 中使用 System.Collections.ArrayList - 需要什么 .NET Framework 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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