确定一个对象是否是 VBA 中集合的成员 [英] Determining whether an object is a member of a collection in VBA

查看:36
本文介绍了确定一个对象是否是 VBA 中集合的成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定一个对象是否是 VBA 中集合的成员?

How do I determine whether an object is a member of a collection in VBA?

具体来说,我需要找出表定义是否是 TableDefs 集合的成员.

Specifically, I need to find out whether a table definition is a member of the TableDefs collection.

推荐答案

你最好的办法是迭代集合的成员,看看是否有任何匹配你正在寻找的.相信我,我不得不多次这样做.

Your best bet is to iterate over the members of the collection and see if any match what you are looking for. Trust me I have had to do this many times.

第二种解决方案(更糟糕)是捕获Item not in collection"错误,然后设置一个标志来表示该项目不存在.

The second solution (which is much worse) is to catch the "Item not in collection" error and then set a flag to say the item does not exist.

这篇关于确定一个对象是否是 VBA 中集合的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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