Alessio9899
New Member
- Joined
- May 10, 2019
- Messages
- 4
Hello everybody! Like the title i need to do this task. I found this code on web that fits perfectly with my goal:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Public Sub ConvertXmlToXlsx()
Application.DisplayAlerts = False
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
xmlFolder = "C:\Users\xxx\xxx\xxx\xxx"
convFolder = "C:\Users\xxx\xxx\xxx\xxx"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(xmlFolder)
For Each objFile In objFolder.Files
If UCase(Right(objFile.Name, Len(XML))) = UCase(XML) Then
NewFileName = convFolder & objFile.Name & ".xlsx"
Workbooks.OpenXML (objFolder & "" & objFile.Name), LoadOption:=xlXmlLoadImportToList
ActiveWorkbook.SaveAs Filename:=NewFileName
ActiveWorkbook.Close
End If
Next objFile
End Sub</code>
It works without any issues as long as there are at least 2 entries in the XML file but there many xml with just one entry and this code doesn't create the right header attribute for each value:
right case(what i need)
[/URL][/IMG]
wrong one
[/URL]
upload photo
[/IMG]
in this last case there's no header and i need all attributes to import these in my neo4j database.
Is there a way to set that script to automatically recognise every attribute for 1 entry xml file? Thanks to everybody
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Public Sub ConvertXmlToXlsx()
Application.DisplayAlerts = False
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
xmlFolder = "C:\Users\xxx\xxx\xxx\xxx"
convFolder = "C:\Users\xxx\xxx\xxx\xxx"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(xmlFolder)
For Each objFile In objFolder.Files
If UCase(Right(objFile.Name, Len(XML))) = UCase(XML) Then
NewFileName = convFolder & objFile.Name & ".xlsx"
Workbooks.OpenXML (objFolder & "" & objFile.Name), LoadOption:=xlXmlLoadImportToList
ActiveWorkbook.SaveAs Filename:=NewFileName
ActiveWorkbook.Close
End If
Next objFile
End Sub</code>
It works without any issues as long as there are at least 2 entries in the XML file but there many xml with just one entry and this code doesn't create the right header attribute for each value:
right case(what i need)
wrong one
upload photo
[/IMG]
in this last case there's no header and i need all attributes to import these in my neo4j database.
Is there a way to set that script to automatically recognise every attribute for 1 entry xml file? Thanks to everybody