title: Producing Excel files in ASP on IIS7.5
body: <p>On an existing web application I support there is a page that is used to produce an Excel spreadsheet for some data. The Web server has Excel 2002 installed (so old...) and makes uses of automation of the Excel object to do the work.</p>
  
  <p>I am fully aware that automating Excel like this is not recommended by Microsoft, but this is the way is currently works, and I am never allocated any time to look to change this.</p>
  
  <p>Here is some sample code</p>
  
  <pre><code>Dim xlApp, xlBook, xlSheet
  
  'create the Application Object and workbook object
  Set xlApp = Server.CreateObject("Excel.Application")
  Set xlBook = xlApp.Workbooks.Add
  Set xlSheet = xlBook.Worksheets.Add
  
  'turn off any alerts
  xlApp.DisplayAlerts = False
  xlApp.Visible = False
  xlApp.ScreenUpdating = False
  xlApp.DisplayFormulaBar = True
  xlApp.CommandBars("Standard").Visible = True
  xlApp.CommandBars("Formatting").Visible = True
  xlApp.CommandBars("Chart").Visible = True
  xlApp.CommandBars("Control Toolbox").Visible = True
  
  xlSheet.Cells(1, 1).Value = "Test"
  
  xlApp.ScreenUpdating = True
  
  xlApp.ActiveWorkbook.SaveAs ("C:\Temp\Test.xls"), -4143
  xlApp.Quit
  
  Set xlApp = Nothing
  </code></pre>
  
  <p>The Web Server is a Windows 2003 server, running IIS6, and everything works happily. However, we are currently upgrading to using Windows 2008 servers, running IIS7.5 and the above code is no longer working. The message returned is as follows:</p>
  
  <pre><code>Microsoft Excel error '800a03ec' 
  
  SaveAs method of Workbook class failed 
  
  xxxxxx/Test_Excel.asp, line 42 
  </code></pre>
  
  <p>The thing is, is that if I create a simple .vbs file, with the above code and run it, it all works as expected. It is only when running as an ASP page does it fail.</p>
  
  <p>The folder is it trying to write to should have the correct permissions (I added 'Everyone' to it, with full access).</p>
  
  <p>Does anyone have any suggestions as to why this is happening?</p>
  
  <p>Thanks!</p>