title: How can I hook up to Excel events in Javascript
body: <p>In a client-side web application, I would like to:</p>
  
  <ol>
  <li>open an Excel spreadsheet,</li>
  <li>export some application data to Excel,</li>
  <li>allow the user to work with it, and</li>
  <li>when they are done, read the (potentially changed) data back into my application.</li>
  </ol>
  
  <p>I would like the user to have a fluid experience and detect when they are done with excel by hooking up to the BeforeClose event, but I find that I am unable to hook up to Excel's events in javascript/HTML.  </p>
  
  <pre><code>function BeforeCloseEventHandler(cancel) {
      // TODO: read values from spreadsheet
      alert("Closing...");
  }
  
  function openExcel() {
      var excel = new ActiveXObject("Excel.Application");
      var workbook = excel.Workbooks.Add();
      var worksheet = workbook.Worksheets(1);
      worksheet.Cells(1, 1).Value = "First Cell";
      worksheet.Cells(1, 2).Value = "Second Cell";
      workbook.BeforeClose = BeforeCloseEventHandler;  // THIS DOESN'T WORK
      excel.Visible = true;
      excel.UserControl = true;
  }
  </code></pre>
  
  <p>Does anyone have any suggestions?</p>