+ Reply to Thread
Results 1 to 3 of 3

Save all xls files in directory as xlsx

  1. #1
    Registered User
    Join Date
    09-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    27

    Save all xls files in directory as xlsx

    I am running a macro to save all Excel 97-03 files in a directory as Excel 07+

    The following macro works, I was just hoping to have all files saved as lowercase .xlsx as opposed to adding on an x to the end - some of my files are in the directory as .XLS and an x added on displays .XLSx after running the macro.

    Sorry if this is silly, and thanks in advance.


    Sub ConvertXlsx()
    Dim strPath As String
    Dim strFile As String
    Dim wbk As Workbook
    ' Path must end in trailing backslash
    strPath = "C:\Users\KARASIA\Downloads\xls\"
    strFile = Dir(strPath & "*.*")
    Do While strFile <> ""

    Set wbk = Workbooks.Open(FileName:=strPath & strFile)
    wbk.SaveAs FileName:=strPath & strFile & "x", _
    FileFormat:=xlOpenXMLWorkbook
    wbk.Close SaveChanges:=False

    strFile = Dir
    Loop

    End Sub
    Last edited by StartRunMSPaint; 10-07-2014 at 04:45 PM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Save all xls files in directory as xlsx

    Try

    Please Login or Register  to view this content.
    Martin

  3. #3
    Registered User
    Join Date
    09-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Save all xls files in directory as xlsx

    Thanks! Works great.

+ 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. [SOLVED] convert xlsx to csv and save to file directory
    By shaz0503 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-27-2014, 07:19 PM
  2. [SOLVED] Looping through all files in a folder - save as xlsx
    By Emse_ in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-18-2014, 02:15 PM
  3. Replies: 0
    Last Post: 03-13-2013, 09:08 PM
  4. Save all .xlsx files in a directory to .xls
    By paul00 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2012, 08:05 PM
  5. Writing to all xlsx files in a directory
    By BretFelix in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2010, 06:34 PM

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