title: Applescript: Open Excel File and Save in a Different Format (same name and path)
body: <p>I have a folder of .xls files of which some are genuine excel files and some are excel xml files (but still with the .xls extension). To work with the files in a separate program, I'm trying to convert them all to a consistent format (Excel 98-2004) and want to use an applescript to do this while retaining the original file names and directory structure.</p>
  
  <p>As of now, I have a working loop and list of files, and am accomplishing everything but the save function:</p>
  
  <pre><code>set file_Name to "/Users/me/path/to/data.xls"
  
  tell application "Microsoft Excel"
      activate
      open file_Name
      save workbook as workbook (active workbook) filename file_Name file format (Excel98to2004 file format) with overwrite
      close workbooks
      quit
  end tell
  </code></pre>
  
  <p>When I run this code, I get the following replies:</p>
  
  <pre><code>tell application "Microsoft Excel"
      activate
      open "/Users/drewmcdonald/Desktop/Madhupur_10February2014.xls"
      get active workbook
          --&gt; active workbook
      save workbook as workbook (active workbook) filename "/Users/drewmcdonald/Desktop/test.xlsx"
          --&gt; missing value
      close every workbook
      quit
  end tell
  </code></pre>
  
  <p>The spreadsheets are successfully opening and closing, but the file format is not changing and I don't know what to make of the "missing value" error. Any idea how to get this to work? Thanks!</p>
  
  <p>EDIT: Just noticed that the file format parameter is missing from the reply text, so I'm guessing the problem is in there.</p>