关于VB6/VBA中的CreateObject()的问题 [英] Question about CreateObject() in VB6 / VBA

查看:370
本文介绍了关于VB6/VBA中的CreateObject()的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以这样做:

Dim fso As New FileSystemObject

或者我可以这样做:

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")

我如何知道用于CreateObject的字符串?例如,我怎么知道如何使用脚本". "Scripting.FileSystemObject"的一部分?你在哪里去找那个?

How do I know what string to use for CreateObject? For example, how would I know to use the "Scripting." part of "Scripting.FileSystemObject"? Where do you go to look that up?

推荐答案

它是 ProgID Windows注册表中HKCR密钥下注册的组件的名称:

It is the ProgID of the component which is registered in Windows registry under HKCR key:

HKEY_CLASSES_ROOT\Scripting.FileSystemObject

ProgID是人类可读的COM对象标识符.它们指向实际的CLSID,在这种情况下为:

ProgID's are human readable identifiers for COM objects. They point to the actual CLSIDs, which in this case is:

HKEY_CLASSES_ROOT\CLSID\{0D43FE01-F093-11CF-8940-00A0C9054228}

在这里您可以找到包含组件实现的实际COM .dll.

This is the place where you can find the actual COM .dll that includes the implementation of the component.

在您提供的第一个示例代码中,您正在进行早期绑定,而在第二个示例代码中,您正在进行后期绑定.

In the first sample code you have provided you are doing an early-binding, and in the second one you are doing a late-binding.

这篇关于关于VB6/VBA中的CreateObject()的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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