如何解决VBA MS-ACCESS仅加载表
我不得不说我不是VBA专家,我主要是用它来查找特定产品的解决方案。
我有一个加载xml的代码,以使用xslt访问和转换此xml。到此为止,一切都可以正常运行。
每次我加载文件夹的同时,都会创建一个新表,其中包含每个文件和路径的名称
我的问题是,是否可以将某些代码添加到While strFile ****中,以避免导入具有已经存储在importaciones表中的名称的文件?
谢谢!
Public Sub TransformAndImportMultipleXMLs()
Dim strFile As String
Dim strPath As String
Dim xmlDoc As New MSXML2.DOMDocument60,xslDoc As New MSXML2.DOMDocument60
Dim newDoc As New MSXML2.DOMDocument60
strPath = "C:\Users\Folder\Subfolder"
strFile = Dir(strPath & "*.xml")
'' LOAD XSLT TO TRANSFORM XML
xslDoc.Load "C:\Users\Folder\Desktop\Subfolder\XSL\LAST6.9.XSL"
'' *****HERE I NEED A FUNCTION TO EXCLUDE IMPORTING FILES WITH NAMES IN TABLE "Importaciones"****
While strFile <> ""
Set xmlDoc = New MSXML2.DOMDocument60
Set newDoc = New MSXML2.DOMDocument60
'' LOAD XML SOURCE
xmlDoc.Load strPath & strFile
'xslDoc.loadXML strPath & strFile
'' TRANSFORM XML AND SAVE IT
xmlDoc.transformNodetoObject xslDoc,newDoc
newDoc.Save "C:\Users\Folder\Desktop\temp.xml"
'' APPEND TO TABLES
Application.ImportXML "C:\Users\Folder\Desktop\temp.xml",acAppendData
strFile = Dir()
Wend
'' RELEASE DOM OBJECTS
Set xmlDoc = nothing: Set xslDoc = nothing: Set newDoc = nothing
'' WE CREATE A TABLE WITH ALL FILE NAMES CALLED "IMPORTACIOnes"
Dim F As Variant
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
DoCmd.SetWarnings False
For Each F In FSO.getFolder(strPath).Files
DoCmd.Runsql "INSERT INTO Importaciones ([FileName],[Path_and_FileName]) VALUES ('" & Mid(F,62,25)
& "','" & F & "');"
Next
DoCmd.SetWarnings True
End Sub
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。