+ Reply to Thread
Results 1 to 20 of 20

Convert xml files to xls without open them?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Convert xml files to xls without open them?

    Hi to all,

    Maybe someone helps me over here.

    I have many xml files (in a format that Excel can read). Even when Excel can open those xml files, I would like to convert them from xml to xls or xlsx.

    I've recorded the following macro that open an xml file and convert it to xlsx.
    Sub XML_to_XLS()
    
        Workbooks.Open Filename:="C:\MyFolder\MyFile.xml"
        ActiveWorkbook.SaveAs Filename:="C:\MyFolder\MyFile.xlsx" _
            , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False '
    End Sub
    Is there a way to say to Excel that convert all xml files in folder to xlsx without open them?

    This because there are 5000 xml files to convert and open and saving files will take so long I think.

    Many thanks in advance.

    Regards.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Convert xml files to xls without open them?

    Can't you just change their extensions to xls?

  3. #3
    Registered User
    Join Date
    07-21-2011
    Location
    RF, Samara
    MS-Off Ver
    Excel 2003&2007
    Posts
    8

    Re: Convert xml files to xls without open them?

    Public Sub xls_xml()
    Application.ScreenUpdating = False
    xlsfolder = "C:\temp\"
    x = Dir(xlsfolder & "*.xls")
    i = 1
    While x <> ""
    Workbooks.Open Filename:="" & xlsfolder & x & "" ActiveWorkbook.SaveAs Filename:="C:\MyFolder\MyFile_" & i & " .xlsx" _ , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False ActiveWorkbook.Close i = i + 1 x = Dir
    wend msgbox "Done" end sub

  4. #4
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Convert xml files to xls without open them?

    Quote Originally Posted by Kyle123 View Post
    Can't you just change their extensions to xls?
    Hi Kyle,

    Thanks for reply. That is what I tryed first, but when I open the file Excel reports that maybe the file is corrupted even when Excel finally is able to open it.
    I think this is because is not converted in in correct way nor completely from xml to binary xls.

    Hi egonomist,

    Many thanks for your help too, I only was wondering if is possible to do it without the need to open each xml file to convert it xlsx.

    Is there an option with ADO o VBA maybe?

    Many thanks in advance for any help.

    Regards
    Last edited by cgkmal; 10-11-2011 at 03:39 PM.

  5. #5
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Convert xml files to xls without open them?

    Somebody knows if this is possible?

    Thanks for any help.

  6. #6
    Registered User
    Join Date
    07-21-2011
    Location
    RF, Samara
    MS-Off Ver
    Excel 2003&2007
    Posts
    8

    Re: Convert xml files to xls without open them?

    it's possible in MS Access If all workbook has a same worksheets name.
    For example, if all worksheets has name "Sheet1" I can help you.

  7. #7
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Convert xml files to xls without open them?

    Many thanks egonomist, the xml files contain 2 sheets, but only I need to do it in MS Excel.

    Many thanks for help so far.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Convert xml files to xls without open them?

    lovedieer,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  9. #9
    Registered User
    Join Date
    11-07-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Convert xml files to xls without open them?

    GOt it . Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1