How to import multiple xml file into excel

Anonymous
2012-09-13T00:07:12+00:00

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?

Microsoft 365 and Office | Excel | For home | Windows

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.

0 comments No comments

66 additional answers

Sort by: Newest
  1. Anonymous
    2015-03-25T17:12:21+00:00

    For the correct sheet, I think it is just modifying

    wb1.Sheets(1).UsedRange.Copy wb.ActiveSheet.Range("A1")

    to

    wb1.Sheets(2).UsedRange.Copy wb.ActiveSheet.Range("A1")

    or perhaps more reliably

    wb1.Sheets("Posted Transactions").UsedRange.Copy wb.ActiveSheet.Range("A1")

    The destination workbook would only have one sheet. The table there being appended.

    Typical instance of an imported table will only be 20 rows but as much as 200.

    (Don't think I need to test how ridiculous having 300+ worksheets in a single workbook would be. An instance for almost every day of the year except Sundays.)

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-03-25T16:06:10+00:00

    tasosK

    So the idea is to have each sheet inside of a workbook contain a different .xml file.  Is that correct?

    Since I have hundreds of .xml files is there a way to modify the macro script you wrote that I was using before to import the .xml files each into a different sheet as opposed to one right after the other in one sheet?   Will these sheets be exportable as .xml files?

    Thank you!

    Jonathan

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2015-03-25T14:42:37+00:00

    Hi,

    try to load only one xml file in a new sheet

    Sub Load_XML_in_a_new_Sht()

    'Mar 13, 2015

    Dim wb As Workbook, wb1 As Workbook

    Set wb = ThisWorkbook

    Dim sPath

    sPath = "c:\folder1\folder2" '<< change path, change

    Dim sFile

    sFile = "sample xml.xml" '<< xml file name, change

    Application.ScreenUpdating = False

    Set wb1 = Workbooks.OpenXML(Filename:=sPath & sFile, LoadOption:=xlXmlLoadImportToList)

    wb.Sheets.Add

    wb1.Sheets(1).UsedRange.Copy wb.ActiveSheet.Range("A1")

    wb1.Close False

    wb.Save

    Application.ScreenUpdating = True

    End Sub

    If the XML (XML Spreadsheet 2003) data defines multiple worksheets, can a specific worksheet be imported other than the first one. (The sourcer actually sends the file with an XLS extension :( ! )

    (Goal is to import from multiple files to single file, with appending enabled for future files. Desired worksheet is named "Posted Transactions" and also "always" appears as second worksheet .

    Was this answer helpful?

    0 comments No comments
  4. Deleted

    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