xml - MS Access: Why does the asynch method cause "Run-time error 424: Object required" on an XML/DOM file?
问题描述
I am trying to write a simple MS Access application to read a collection of files in XML format. I've written a few lines of code that should take a document name supplied via a form, open the document, a display some detail of the contents. However, the code always fails at a preliminary step with the asynch method. Taking this out would cause the rest of the code to execute before the document is loaded so it is a mandatory step.
I've checked the libraries referenced and tried to instantiate the document as "microsoft.XMLDOM", "MSXML2.DOMDocument" and "MSXML2.DOMDocument.6.0" but still get the same error.
The code fails at the line "Set xmlDoc.async = False" with run-time error 424.
The libraries referenced are:
Visual Basic for Applications
Microsoft Access 14.0 Object Library
OLE Automation
Microsoft Office 14.0 Access database engine Object Library
Microsoft XML, v6.0
Option Compare Database Option Explicit Private Sub ProcessButton_Click() Dim xmlDoc As Object Dim xmlSourceList As Object Dim xmlSource As Object Set xmlDoc = CreateObject("MSXML2.DOMDocument.6.0") Set xmlDoc.async = False xmlDoc.Load (Me.ReportFilename) Set xmlSourceList = xmlDoc.selectSingleNode("//DataSources") For Each xmlSource In xmlSourceList.childNodes MsgBox xmlSource.Attributes.getNamedItem("Name").Text Next xmlSource End Sub
解决方案
设置“某些对象”= true/false 不是您想要的。
你要:
xmlDoc.async = False
使用“set”这个词是为了设置一个对象,而不是改变 xml doc 的某些属性或方法。
推荐阅读
- java - 为什么我的代码仍然在 URI 上显示错误的答案?
- android - 我想更改菜单导航栏中的一项(颜色和图标)或添加文本(新的红色)
- flutter - 如何从 Picker Flutter 小部件中删除灰色框
- php - Laravel 应用程序重定向到 /home,即使它没有在整个应用程序中定义
- vue.js - 如何以树状结构查看 vue 项目中的所有组件?
- azure-keyvault - 对于 Azure Key Vault,是否有可能在单个 keyvault 中使用不同的机密来访问不同的资源(是/否)?如果是,如何?
- sql - SQL LOADER 中的连接常量和动态字段
- firebase - Firebase Fastlane 构建失败,未找到请求的实体
- animation - SVG没有在中心设置动画
- function - 返回卷 usinf Security() 函数中的问题