Excel vba导入多个xml



这是我的第一篇文章,请见好就收!我试图使用模式导入多个xml文件,但使用单元格引用作为文件名的一部分。单元格引用是一个员工编号,所以这只会导入文件名中带有该用户ID的xml文件。

但是,它只将一个文件导入到我的schema表中,而不是多个。

Sub ImportMyFiles()
Dim strFile As String, strPath As String, Num As Long, LR As Integer, UsrID As String
UsrID = Sheets("All_Fields").Range("A2")
strPath = "C:QuAD_Output"
strFile = Dir(strPath & UsrID & "*.xml")
Num = 0
While strFile <> ""
ActiveWorkbook.XmlMaps("QuAD_Schema_Map1").Import URL:= _
(strPath & strFile)
strFile = Dir
Num = Num + 1
LR = Cells(Rows.Count, "A").End(xlUp).Row
LR = LR + 1
Cells(LR, "A") = strFile
Wend
MsgBox "This code ran successfully for " & Num & " XML file(s)", vbInformation
End Sub`

如上所述,设法解决了表属性的问题。希望这对其他人有帮助

最新更新