.xml to .xlsx Code need explained

mayoung

Board Regular
Joined
Mar 26, 2014
Messages
172
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I found this code online to convert .xml to .xlsx. Can someone please explain what I need to do to make this work for for me?
Here is what I am trying to convert:

From: C:\user\myoung\downloads\Dataminer.xml

To: C:\user\myoung\downloads\Dataminer.xlsx

Is this code saying to use two folders named xml Folder and convFolder
Where would these folders go?

VBA Code:
Dim objFolder As Object
Dim objFile As Object

xmlFolder = "C:\Users\John\Documents\xml\"
convFolder = "C:\Users\John\Documents\xls\"


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 & "_conv.xlsx"

        Set ConvertThis = Workbooks.Open(objFolder & "\" & objFile.Name)
        ConvertThis.SaveAs Filename:=NewFileName, FileFormat:= _
        xlOpenXMLWorkbook
        ConvertThis.Close
    End If
Next objFile
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

mayoung

Board Regular
Joined
Mar 26, 2014
Messages
172
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I found this code online to convert .xml to .xlsx. Can someone please explain what I need to do to make this work for for me?
Here is what I am trying to convert:

From: C:\user\myoung\downloads\Dataminer.xml

To: C:\user\myoung\downloads\Dataminer.xlsx

Is this code saying to use two folders named xml Folder and convFolder
Where would these folders go?

VBA Code:
Dim objFolder As Object
Dim objFile As Object

xmlFolder = "C:\Users\John\Documents\xml\"
convFolder = "C:\Users\John\Documents\xls\"


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 & "_conv.xlsx"

        Set ConvertThis = Workbooks.Open(objFolder & "\" & objFile.Name)
        ConvertThis.SaveAs Filename:=NewFileName, FileFormat:= _
        xlOpenXMLWorkbook
        ConvertThis.Close
    End If
Next objFile
I figured this code out it works perfect
 

Watch MrExcel Video

Forum statistics

Threads
1,127,151
Messages
5,623,058
Members
415,949
Latest member
mcrandall99

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
Top