title: COMException Breakdown
body: <p>Does anyone know if a site (even non-Microsoft), that has details on COMExceptions/HRESULTS.</p>
  <p>When I attempted to Save my Excel Workbook after using the Copy() function, I received this error:</p>
  <pre><code>ERROR - Unable to SaveWorkbook()
  System.Runtime.InteropServices.COMException (0x800A03EC): Document not saved.
  </code></pre>
  <p>P.S.  I'm doing this in a tight loop for 10K+ files, but reading the files worked out fine, but saving them is proving to be not fun.</p>
  <p>Also, if anyone has had the issue of Excel hemorrhaging memory when you use the Copy() function let me know.</p>
  <p>Thanks!</p>
  <p>P.S.S If anyone needs further clarification please let me know</p>
  <h1>Edit 1</h1>
  <p>Here's what's going on.  I've been asked to update some XLS files (10K+ in fact), by copying the Active Sheet to a new Sheet (same Workbook) and update the original Sheet by performing some conversion.  The problem comes when I save the Workbook.</p>
  <p>Here is some excerpts from my application:</p>
  <pre><code>///.... UpdateSpreadsheet() Routine
  Microsoft.Office.Interop.Excel.Workbook wb = null;
  
  try
  {
      wb = ef.GetWorkbook(fileName, false, true);
  }
  catch (Exception ex)
  {
      logger.Error(ex.ToString());
  }
  
  Microsoft.Office.Interop.Excel.Worksheet ws = null;
  
  try
  {
      ws = wb.Sheets[Foo.WorksheetName] as Microsoft.Office.Interop.Excel.Worksheet;
  }
  catch (Exception ex)
  {
      logger.Error(ex.ToString());
  }
  
  bool result = false;
  
  if (ws != null)
      result = ef.CopyWorksheet(ws, Foo.WorksheetName);
  
  if (result)
  {
     //... update the sheet as appropriate
  }
  
  try
  {
      ef.SaveWorkbook(wb, fileName);  //eventually this line crashes, it's random, but so far after the 500th file, and I get that COM Exception.
      //.. update Foo object to reflect copied worksheet
  }
  catch (Exception ex)
  {
      //something happened, we can't save, so close and destroy the workbook
      logger.Error(&quot;Unable to SaveWorkbook()&quot;, ex);   
  }
  finally
  {
      ef.DestoryWorkbook(wb, fileName);
      ef.DestroyWorksheet(ws);
  }
  
  //// CopyWorksheet() Method
  public bool CopyWorksheet(Worksheet ws, String sourceSheet)
  {
      try
      {
          try
          {
              Worksheet sheet = GetWorksheet(sourceSheet + &quot; (2)&quot;);
  
                      //I don't think the below is necessary, but I'm paranoid about memory leaks
              ExcelTools.OfficeUtil.ReleaseRCM(sheet);
              sheet = null;
  
              return false;
          }
          catch (Exception)
          {
              ws.Copy(Missing.Value, ws); //this line never errors out
          }
          
          return true;
      }
      catch (Exception)
      {
          return false;
      }
      finally
      {
          ws.Activate();
      }
  }
  
  /// SaveWorkbook()
  public void SaveWorkbook(Workbook wb)
  {
      if (wb != null)
      {
          wb.Save();
      }
  }
  </code></pre>