+ Reply to Thread
Results 1 to 22 of 22

How to Rename the files extension in a Specific Folder

  1. #1
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    How to Rename the files extension in a Specific Folder

    Team,

    In a Cell we will mention the Path of the Folder, lets Say we have in K2 Cell.

    When we click on the button - Based on the Path in K2 Cell we need to change the extensions of the files which has .xml to .XLS

    .XML --- > .XLS

    Please do let me know if I am not clear.

    Thanks!
    Kiran

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: How to Rename the files extension in a Specific Folder

    so you Arent trying to change the extension, you are trying to open, then save AS XLS, correct?
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to Rename the files extension in a Specific Folder

    This link perhaps, see post #14

    http://www.excelforum.com/excel-prog...open-them.html


    Alf

  4. #4
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: How to Rename the files extension in a Specific Folder

    Hi Alf,

    I tried using the below code and it is working fine for me.

    But I need this code to be changed for n number of files in a specific folder. Could you please help me on this.

    Please Login or Register  to view this content.
    Thanks!
    Kiran

  5. #5
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: How to Rename the files extension in a Specific Folder

    If this helps, you can process an entire folder with something like
    dir("C:\MyFolder\*.xlsx") 'first call, returns the first file matching the spec
    followed by a loop of
    dir 'return subsequent files matching that filespec

    I sometimes use something like this, testing the return value of each Dir.
    Please Login or Register  to view this content.
    Chip, if you can read this, you're STILL making the world a better place with your immeasurably valuable gifts. Every week, you continue to help me (and untold numbers of others) tremendously. Practically no alternative outlets can match your effectiveness, even over the vast number of topics you demystify and empower usage of. You were, and still are, amazing.

  6. #6
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: How to Rename the files extension in a Specific Folder

    As this is somewhat urgent, I raised the request in another forum also.
    Last edited by Kandavalli.Kiran; 03-10-2015 at 08:16 AM.

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to Rename the files extension in a Specific Folder

    This will loop through all xml files in the foder specified by sPath

    Please Login or Register  to view this content.
    Alf

  8. #8
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: How to Rename the files extension in a Specific Folder

    As this is somewhat urgent, I raised the request in another forum also.
    That's fine.. but..

    Do you think you should post your cross post link here so those trying to help might not possibly waste their valuable time?

  9. #9
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: How to Rename the files extension in a Specific Folder

    Alf,

    I tried using the above Code and ran the Macro but it is not generating the file with .XLS.

    Attached is one of the File in a directory which I want to Convert.

    Thanks!
    Kiran
    Attached Images Attached Images

  10. #10
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to Rename the files extension in a Specific Folder

    Ok let's try Leith Rosse's code (the thread I linked to in post #3 and see if this works better. By the way the code I used in previous post I used the saving part of the code you said worked.

    Please Login or Register  to view this content.
    Let's hope this works better. If it does don't forget to give rep points to Leith.

    Alf

  11. #11
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: How to Rename the files extension in a Specific Folder

    Hi Alf,

    I have used the above code and it is throwing me an error at the below line.

    Set Wkb = Workbooks.Open(Filename)

    Wkb is shown as Nothing if I place Cursor on it.

    Thanks!
    Kiran

  12. #12
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to Rename the files extension in a Specific Folder

    Could you check that there is only one blank space in the string "Filename = Dir(Filepath & "*.xml*")"

    To me it look like I've managed to get an extra space between Filepath and the &

    Alf

  13. #13
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: How to Rename the files extension in a Specific Folder

    Alf,

    I don't have an extra space in the code.

    when I place the cursor it is showing the correct File Name. Please see attached.

    Thanks!
    Kiran
    Attached Images Attached Images

  14. #14
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to Rename the files extension in a Specific Folder

    Having tested the code written by Leith Ross and I can't get it to work on the only xml file I got on my computer. Found this link and tested this code and it seems to work on the xml file I got.

    http://stackoverflow.com/questions/1...folder-by-vbsc

    Alf

  15. #15
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: How to Rename the files extension in a Specific Folder

    For your open failure, consider chDrive and chdir prior to using the files. It may be redundant but I'd do it to at least eliminate/limit uncertainty.

    chDrive(filepath)
    chdir(filepath)
    Then act on filename

  16. #16
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: How to Rename the files extension in a Specific Folder

    Alf,

    The code in the link which you have provided is working fine. Thank you so much. You help me previously also. Thankssssssssssssssss!

    Instead of .XLS Can we change to .CSV from .XML files. If so, please let me know where to change the code please.

    .XML ---> .CSV

    Thanks!
    Kiran
    Last edited by Kandavalli.Kiran; 03-26-2015 at 10:20 PM.

  17. #17
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to Rename the files extension in a Specific Folder

    Instead of .XLS Can we change to .CSV from .XML files.
    I really don't know. It's getting late here in Sweden but I'll have a go at it tomorrow.

    If worst comes to worst you could do it as a two stage rocket i.e. xml to xls to csv but I assume xml to csv should be possible. Could you perhaps upload 2 or 3 xml files that I could use for testing?

    As the forum don't accept upload of xml files just rename them to xls then I can rename them back to xml.

    Alf

  18. #18
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to Rename the files extension in a Specific Folder

    Have not managed to convert xml to csv, still there are some programs that do this and here is a link to a freebee

    https://xmltocsv.codeplex.com/

    Then there is the possibility as I mentioned before i.e. convert xml to xls and then convert xls to csv.

    Alf

  19. #19
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: How to Rename the files extension in a Specific Folder

    Please find it attached
    Last edited by Kandavalli.Kiran; 04-24-2015 at 10:36 AM.

  20. #20
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to Rename the files extension in a Specific Folder

    Can't see any attachment.

    Happy Easter!

    Alf

  21. #21
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: How to Rename the files extension in a Specific Folder

    Sorry for the delay I got the Solution. Thanks!
    Last edited by Kandavalli.Kiran; 05-08-2015 at 05:18 PM.

  22. #22
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to Rename the files extension in a Specific Folder

    Sorry for the delay I got the Solution. Thanks!
    Think nothing of it, but as a matter of intrest could please post you solution as this may be of help to others struggling with a similar problem.

    Alf

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Rename .pdf files in a folder
    By vijanand1279 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-11-2019, 01:11 AM
  2. rename files in folder
    By anilg0001 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2014, 08:22 AM
  3. Replies: 1
    Last Post: 01-15-2013, 03:05 AM
  4. [SOLVED] rename files in a folder
    By Varun Nair in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-18-2006, 05:05 AM
  5. rename all files in a folder
    By DIBS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-05-2006, 02:50 AM

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