HI All.
I am getting belowerror while converting XML file to excel.
1) Con-Ledger-2015-03-31.xml
2) Std-Ledger-2015-03-31.xml
I have 2 files in a folder I am able to convert the firstfile were as 2nd file shows the below error.
The xml file cannot be opened because of error check to makesure the file is valid XML file , and that the XML syntax is correct. You canalso try recreating the file and closing the other applications before youattempt to open it again.
Could you please help
Below is the code i am using
Public Sub convert()
Application.DisplayAlerts = False
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
xmlFolder ="C:\Users\chandresh.choudhary\Desktop\Test"
convFolder ="C:\Users\chandresh.choudhary\Desktop\Test\Output"
Set objFSO =CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(xmlFolder)
For Each objFile In objFolder.Files
IfUCase(Right(objFile.Name, Len(XML))) = UCase(XML) Then
NewFileName =convFolder & objFile.Name & "_conv.xlsx"
SetConvertThis = Workbooks.Open(objFolder & "" & objFile.Name)
ConvertThis.SaveAs Filename:=NewFileName, FileFormat:= _
xlOpenXMLWorkbook
ConvertThis.Close
End If
Next objFile
End Sub
I am getting belowerror while converting XML file to excel.
1) Con-Ledger-2015-03-31.xml
2) Std-Ledger-2015-03-31.xml
I have 2 files in a folder I am able to convert the firstfile were as 2nd file shows the below error.
The xml file cannot be opened because of error check to makesure the file is valid XML file , and that the XML syntax is correct. You canalso try recreating the file and closing the other applications before youattempt to open it again.
Could you please help
Below is the code i am using
Public Sub convert()
Application.DisplayAlerts = False
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
xmlFolder ="C:\Users\chandresh.choudhary\Desktop\Test"
convFolder ="C:\Users\chandresh.choudhary\Desktop\Test\Output"
Set objFSO =CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(xmlFolder)
For Each objFile In objFolder.Files
IfUCase(Right(objFile.Name, Len(XML))) = UCase(XML) Then
NewFileName =convFolder & objFile.Name & "_conv.xlsx"
SetConvertThis = Workbooks.Open(objFolder & "" & objFile.Name)
ConvertThis.SaveAs Filename:=NewFileName, FileFormat:= _
xlOpenXMLWorkbook
ConvertThis.Close
End If
Next objFile
End Sub