title: How can I create a new Excel 2011 spreadsheet and save it to a particular directory/filename using Applescript
body: <p>I am trying to write an Applescript program to create a spreadsheet, add data to it, and save the spreadsheet in a particular folder. I have code to create, fill-in, and save the spreadsheet, but I'm not able to specify the folder where the new file is to be saved.</p>
  
  <p>The file is saved in the last folder where I saved a spreadsheet. If I include the full path to the folder where I want it saved("/Users/david/Documents/test/foo.xls"), Excel 2011 creates a file named ":Users:david:Documents:test:foo.xls" in the folder where I had previously manually saved a spreadsheet. So for example, if I manually open Excel and create a spreadsheet and save it in a subfolder of my <code>Documents</code> folder named <code>important</code>, and now run the following script, the file will be created in the <code>important</code> folder, not the <code>test</code> folder.</p>
  
  <pre><code>tell application "Microsoft Excel"
      set wb to make new workbook
      tell active sheet
          -- Lots of code to fill in the data
      end tell
      set fn to "/Users/david/Documents/test/foo.xls"
      save workbook as wb filename fn file format Excel98to2004 file format overwrite yes
      close active workbook saving no
  end tell
  </code></pre>
  
  <p>From various posts I've read, it appears one should be able to specify the full path, but the questions usually deal with previous versions of Excel. Also, I'm running Mountain Lion if that makes a difference.</p>