title: How do I run an Excel Macro from a .Net web system?
body: <p>I'm trying to run an Excel Macro called <code>Sheet1.Workbook_Open</code> from a .NET web system.</p>
  
  <p>Below is my current code.</p>
  
  <pre><code>xlApp = New Excel.Application
  xlWorkBook = xlApp.Workbooks.Open("C:\Testing\TempFile.xlsm")
  xlWorkSheet = xlWorkBook.Worksheets("TestSpreadsheet")
  
  Dim MacroName As String = "Sheet1.Workbook_Open"
  
  xlApp.Run(MacroName)
  
  Dim FileDate As String = SysdateTextBox.Text
  FileDate = FileDate.Replace(" ", "")
  FileDate = FileDate.Replace("/", "")
  FileDate = FileDate.Replace(":", "")
  
  FileName = "C:\Testing\File" &amp; FileDate &amp; ".xlsm"
  
  xlWorkBook.SaveAs(FileName)
  xlWorkBook.Close(True)
  xlApp.Quit()
  </code></pre>
  
  <p>However, it fails on the line <code>xlApp.Run(MacroName)</code> with the error;</p>
  
  <pre><code>Exception from HRESULT: 0x800A01A8 
  
  System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A01A8
  </code></pre>
  
  <p>Why is this happening, and how can I fix it? This error doesn't happen when the project is hosted on my local machine - only when it is on the server.</p>