gpt4 book ai didi

ms-access - VBA CreateObject ("MSXML2.DOMDocument60") 引发错误 429

转载 作者:行者123 更新时间:2023-12-04 19:35:29 25 4
gpt4 key购买 nike

我在使用 CreateObject() 声明新对象时遇到问题

Sub A()
Dim x

'This works
Set x = CreateObject("Scripting.FileSystemObject")
Set x = Nothing

'This throws an error 429 "Active component cannot create object."
Set x = CreateObject("MSXML2.DOMDocument60")
Set x = Nothing

'The only way I can create object is to add the reference using GUID
Dim y As MSXML2.DOMDocument60
Set y = New MSXML2.DOMDocument60
Set y = Nothing
'This works like a charm

End Sub

我不明白为什么“脚本”有效而“MSXML2”无效。

我在 Windows 7 64 位上使用 MS Access 2010 32 位。

最佳答案

使用后期绑定(bind)时,您并不总是使用相同的名称。 ActiveX 对象需要 OLE Programmatic Identifier要使用的。

将其更改为:

Set x = CreateObject("MSXML2.DOMDocument.6.0")

来自 MSDN 文章 Building MSXML Applications :

When you are using a scripting language, you can identify the control via its ProgID, which is a form that is quite a bit easier to read by a human. An example of a ProgID is Msxml2.DOMDocument.6.0.

关于ms-access - VBA CreateObject ("MSXML2.DOMDocument60") 引发错误 429,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37046460/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com