Run Time error 1004 while converting XML file

Chandresh

Board Regular
Joined
Jul 21, 2009
Messages
146
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
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top