title: find all open Excel workbooks
body: <p>I'm trying to get a list of all currently open Excel workbooks, so that the user can select which one of them to get some data from.</p>
  
  <p>I tried this:</p>
  
  <pre><code>List&lt;string&gt; excelList = new List&lt;string&gt;();
  Process[] processList = Process.GetProcessesByName("excel");
  foreach (Process p in processList)
  {
   excelList.Add(p.MainWindowTitle);
   Console.WriteLine(p.MainWindowTitle);
  }
  </code></pre>
  
  <p>But that only gets the first open instance of Excel and the most recently opened instance, so any workbooks that were opened between those two aren't in the list.</p>
  
  <p>I also started exploring the solution described in the <a href="http://blocko.blogspot.com/2006/10/driving-excel-and-powerpoint-with-c.html" rel="nofollow noreferrer">blog link</a> in the answer to <a href="https://stackoverflow.com/questions/393167/net-interop-find-all-instances-of-of-a-running-com-object-with-c-sharp">this SO question</a>, and tried to get access to the Running Object Table with the code suggested in the blog entry:</p>
  
  <pre><code>IBindCtx bc;
  IRunningObjectTable rot;
  CreateBindCtx(0, out bc);
  bc.GetRunningObjectTable(out rot);
  </code></pre>
  
  <p>Problem here is that <code>CreateBindCtx</code> actually accepts a <code>UCOMIBindCTX</code> instead of <code>IBindCTX</code>, but <code>UCOMIBindCTX</code> is obsolete per <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.ucomibindctx.aspx" rel="nofollow noreferrer">MSDN</a>.</p>
  
  <p>Is there a simpler way to do what I'm trying to do: get a list of <code>Workbook</code> objects corresponding to all the open Excel books?</p>