Friday, August 15, 2014

Free Convert for Excel files (.xls to .xlsx)

I was pleasantly surprised that Excel 2010 has a command line tool that will convert .xls to .xlsx files. Here is how you use it.

In this example we are converting a file called MyFile.xls in the temp directory to MyFle.xlsx in the same temp directory. I didn't have any luck getting this to work without using absolute path.

  1. Open a command prompt 
  2. Execute the following (after adjusting it to meet your specific environment:
    "C:\Program Files\Microsoft Office\Office14\excelcnv.exe" -oice "C:\temp\MyFile.xls" "C:\temp\MyFile.xlsx"


Since this is command line driven you can script many files easily.


@ECHO OFF
FOR %%X in (".\*.xls") DO IF NOT %%~xX == .xlsx echo Converting "%%~dpnxX"  & "C:\Program Files\Microsoft Office\Office14\excelcnv.exe"  -nme -oice "%%~dpnxX" "%%~dpnX.xlsx" 


WARNING: For some reason Excel may tell you that it didn't launch correctly and ask you if you want to run it in safemode. I have no clue as to why this is, but clicking No each time seems to work fine. It will do this for each file.

10 comments:

  1. Brent,
    Did you ever find a solution to Safe Mode popup message?

    ReplyDelete
  2. Hi - did you ever found a solution for safe mode popup? I am automating the conversion and dont know how I can suppress the popup or choose a default. Any inputs?

    ReplyDelete
  3. Hi! Thank you for this instruction, it was very helpful.
    And i have found a way to remove safe mode error!
    After every use of excelcnv you need to remove registry key by using "reg delete HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Excel\Resiliency\StartupItems /f"
    (change version in "\15.0\" to your version)

    ReplyDelete
  4. Excellent, thanks for the registry key fix makes converting large numbers of files a breeze now.

    ReplyDelete
  5. Thanks !! This helped me a lot!!

    ReplyDelete
  6. Can the excelcnv.exe file be copied from a PC that has it to another PC (Has Excel 2007 on it) and used as described?

    Thanks,

    ReplyDelete
  7. What does the -oice do? I've also seen -nme also without explanation.

    ReplyDelete
  8. Here is what you could use as well https://freetools.site/document-converters/xls-to-xlsx

    ReplyDelete
  9. This scripting solution sounds very efficient.

    ReplyDelete