+ Reply to Thread
Results 1 to 20 of 20

Convert xml files to xls without open them?

  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.
    Please Login or Register  to view this content.
    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?

    Please Login or Register  to view this content.

  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 Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Convert xml files to xls without open them?

    Hello cgkmal,

    You can convert Office program files from XML to their binary file formats using the free Microsoft converter. Once installed, it will automatically convert a XML file into an .xls, .doc, .ppt, etc. However, it may not always work correctly as there are new features in the XML files that did not exist in the old binary files. In my experience it works about 98% of the time without problems.

    Here is the download link. IMPORTANT: Read all the information first before you download!
    Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint File Formats
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  9. #9
    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?

    Hello Leith,

    Thanks for your reply.

    I've seen the link you provided me, even I installed the fileconverter, but
    I think it wasn't needed for me, because I'm using Excel 2010.

    I can open and convert (SaveAs) the xml files into xlsx or xls files, but I have a few thousand of xml files and I have to do that conversions one by one and open and saving, open and saving.

    I recorded the macro I show above in my first post, but I was wondering if it is possible to do the same thing without open the xml files, only convert all the xml files in folder to xls or xlsx.

    Maybe with ADO or with other VBA code.

    I would like to avoid open and save, open and save, to not turn in a slow execution and to save resources, because there are thousands of files.

    Many thanks for any help.

    Regards.

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Convert xml files to xls without open them?

    Hello cgkmal,

    With Excel 2010 you can save the file in a older format such as Excel 2003 or earlier. The workbooks can resaved using the SaveCopyAs method in VBA. You don't have to open the workbook to do a SaveCopyAs. Are all the files in the same folder?

  11. #11
    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?

    Leith,

    Yes, the xml files are all in the same folder.

    How would be some example of save them without open as original binary xlsx or xlx files?

    Thanks for help so far

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Convert xml files to xls without open them?

    Hello

    Instead of using the SaveCopyAs, I think this approach should work. The macro renames the files in the folder if they have an xlsx, xlsm extension to an xls. When you open the file, Windows should convert it automatically from xml to the older binary format.
    Please Login or Register  to view this content.

  13. #13
    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?

    Leith,

    Thanks for your help, it work almost as need. Convert extension without open the files, the only issue is that when
    I open the new files in Excel, I receive a window saying the file doesn't have the format especified by the file extension.

    That problem is avoided if I do "SaveAs". I think the solution should be using "SaveCopyAs" as you said before.

    The only thing I think I need is to put the files that is currently reading by Dir(), as Workbook object to do "Expression.SaveCopyAs", where Expression is a workbook object.

    May you help to finish this, saying me how to set the file that is currently read with Dir () as workbook object?

    Something like:
    Please Login or Register  to view this content.
    I know that is wrong, only I don't know how to set the expression.

    Thanks again for your help.

  14. #14
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Convert xml files to xls without open them?

    Hello cgkmal,

    Well, it was worth a try. Unfortunately, the SaveCopyAs doesn't allow you specify the file format, just the file name. So, the results using SaveCopyAs would be the same. There doesn't seem to be a way around having to open the workbook to convert it. This macro will do it for you but it make take some time to do 1,000 or more workbooks.
    Please Login or Register  to view this content.

  15. #15
    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?

    That code works Leith, if it is possible only Save opening the files I'll have to do it in that way.

    Many thanks for your kindly help Leith. Great support.

    Best regards

  16. #16
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Convert xml files to xls without open them?

    Hello cgkmal,

    Usted es bienvenido. I was in Tegucigalpa in the 1970s. It was quite an experience. I was acting as an interpreter for a man who worked for my father. He recently had been to Yugoslavia in the past 2 months and the other man we met with was Guatemalan. The airport guards got very suspicious and we were detained for 2 and half hours. They though we might be communists. I laugh it about it now, but then it was very serious.

  17. #17
    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?

    Muchas gracias Leith,

    Nice to know that you were in my country, sorry for that bad experience, in those years I think they where doing those
    kinds of registers because of Cold War and things like that :D.

    Now has been change a lot, many people from many countries visit us, principally visiting Bay Islands, other beaches
    and Mayan ruins of Copan, but there is colonial tourism either as you could observe I imagine.

    Thanks to share that experience and much appreciated for the help.

    Best regards Leith from Tegucigalpa.
    Last edited by cgkmal; 10-12-2011 at 11:03 PM.

  18. #18
    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?

    hi, i have the same situation and found this post and therefore this forum. I do not have any experience on excel vba or macro. I used SAS ods tagset.excelXP and 5000 xml files were created, and need to convert them in xls or xlxs. they have the different names for example sample1.xml, test3.xml, and control4.xml, each one has two work sheets. i need to save as the same name but with excel suffix.

    Looks like the problem are solved, but can somebody tell me where/how do i put these code and how it work? many many thanks. Please treat me as a dummy, the more detail the better. Thanks.



    Quote Originally Posted by Leith Ross View Post
    Hello cgkmal,

    Well, it was worth a try. Unfortunately, the SaveCopyAs doesn't allow you specify the file format, just the file name. So, the results using SaveCopyAs would be the same. There doesn't seem to be a way around having to open the workbook to convert it. This macro will do it for you but it make take some time to do 1,000 or more workbooks.
    Please Login or Register  to view this content.

  19. #19
    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]

  20. #20
    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