A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
You may refer the article given below for more information on how to import multiple XML data files into Excel, and check if that helps.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a lot of xml files which need to be imported into single excel file. I can able to import one by one but cannot select all at a time to import.
Is it possible to do through batch process or any other process?
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
You may refer the article given below for more information on how to import multiple XML data files into Excel, and check if that helps.
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more
TasosK,
Thank you again for this wonderful code. I have a few questions, as I am not getting the desired results
Set cH = WB.Sheets(1).Range(Cells(1, 1), Cells(1, c)).Find(What:=myWB.Sheets(1).Cells(1, x), SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
If I leave row one blank, I get only one column imported (Version) and repeated as many times as the Const N As Long column number. In this case it was 3
| A | B | C | |
|---|---|---|---|
| 1 | /my:Version | /my:Version | /my:Version |
| 2 | v. AP 2.0 | v. AP 2.0 | v. AP 2.0 |
| 3 | /my:Version | /my:Version | /my:Version |
| 4 | v. AP 2.0 | v. AP 2.0 | v. AP 2.0 |
<?xml version="1.0" encoding="utf-8"?>
<?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:eGOR--Domestic-A-M:-myXSD-2013-06-24T11-56-50" solutionVersion="1.0.0.687" productVersion="12.0.0.0" PIVersion="1.0.0.0" href="URL HERE"?>
<?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?>
<my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-06-24T11:56:50" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-US">
<my:Header>
<my:Date>2013-10-16</my:Date>
<my:Location>AAA</my:Location>
<my:Part>558</my:Part>
<my:Verified>Yes</my:Verified>
<my:Pairs>AAABBB</my:CPairs>
<my:Room>B5</my:Room>
<my:Name>CARLOS</my:Name>
<my:Manager>BOB</my:Manager>
<my:Supervisor>JEN</my:Supervisor>
</my:Header>
<my:Version>v. AP 2.0</my:Version>
</my:myFields>
| /my:myFields | |||
|---|---|---|---|
| /@xml:lang | /my:Header/my:Date | /my:Header/my:Location | /my:Header/my:Part |
| en-US | 10/16/2013 | AAA | 558 |
Once again, thank you for your wisdom. What will I need to place in row one to get the columns Date, Location, and Part to import for each file. I have used this code and cannot get it to work. Does the /Header/ folder before the field name affect the import with this code?
I was able to find the solution. I made it reference the second row in the XML documents due to the first row just containing /my:my:Fields
Thanks for everything,
TPearl
Sub Convert_XML_Files()
On Error GoTo errh
Const N As Long = 3 '<<< number of headers/columns in row 1,change
Dim myWB As Workbook, WB As Workbook
Set myWB = ThisWorkbook
Application.ScreenUpdating = False
Dim myPath
myPath = "C:\Users\tp62215\Desktop\New folder" '<<< change path
Dim myFile
myFile = Dir(myPath & "*.xml")
Dim t As Long, r As Long, c As Long, x As Long
t = 2
Dim cH As Range
Do While myFile <> ""
Set WB = Workbooks.OpenXML(Filename:=myPath & myFile)
r = WB.Sheets(1).Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
c = WB.Sheets(1).Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
For x = 1 To N
Set cH = WB.Sheets(1).Range(Cells(1, 1), Cells(2, c)).Find(What:=myWB.Sheets(1).Cells(1, x), SearchOrder:=xlByColumns, SearchDirection:=xlPrevious) '.Column
If Not cH Is Nothing Then
WB.Sheets(1).Range(Cells(2, cH.Column), Cells(r, cH.Column)).Copy myWB.Sheets(1).Cells(t, x)
End If
Next
WB.Close False
t = myWB.Sheets(1).Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
myFile = Dir()
Loop
Application.ScreenUpdating = True
myWB.Save
Exit Sub
errh:
MsgBox "no files xml"
End Sub
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more