[英]Using VBA to Import XML into MS Access with xslt transform file
我正在尝试将一堆.xml文件导入Access表。 我创建了一个.xslt文件,当我在Access中手动运行导入时,该文件可以正常工作。 但是,当我尝试使用VBA代码(从另一篇文章中提取的代码)转换.xml文件时,生成的temp.xml文件完全为空。 我想念什么?
Public Sub TransformAndImportMultipleXMLs()
Dim strFile As String, strPath As String
Dim xmlDoc As New MSXML2.DOMDocument60
Dim xslDoc As New MSXML2.DOMDocument60
Dim newDoc As New MSXML2.DOMDocument60
strPath = "y:\"
strFile = Dir(strPath & "*.xml")
xslDoc.async = False
xslDoc.validateOnParse = False
xslDoc.resolveExternals = False
xslDoc.Load "C:\JSTAdb\LinkIncidentID.xslt"
While strFile <> ""
' REINITIALIZE DOM OBJECTS
Set xmlDoc = New MSXML2.DOMDocument60
Set newDoc = New MSXML2.DOMDocument60
' LOAD XML SOURCE
xmlDoc.Load strPath & strFile
' TRANSFORM SOURCE
xmlDoc.transformNodeToObject xslDoc, newDoc
newDoc.Save "C:\JSTAdb\temp.xml"
' APPEND TO TABLES
Application.ImportXML "C:\JSTAdb\temp.xml", acAppendData
strFile = Dir()
Wend
'RELEASE DOM OBJECTS
Set xmlDoc = Nothing: Set xslDoc = Nothing: Set newDoc = Nothing
End Sub
我想到了。 .xml文件来自InfoPath表单,其中包含许多大型照片附件。 我没有等待足够长的时间来转换结果。 我只需要一点耐心。 现在工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.