问题描述
我不得不说我不是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 (将#修改为@)