title: Excel interop: Restore minimized window
body: <p>In my winforms app interacting with Excel through the com interop,</p>
  
  <p>I'm trying to attach to an existing Excel process if there is one. Getting the object seems to work well, but if the Excel application is minimized (which is quite likely in my use case), I don't manage to restore the window and bring it to the front.</p>
  
  <p>I've tried the following statements:</p>
  
  <pre><code>try
      app = (Excel.Application)Marshal.GetActiveObject("Excel.Application");
  catch (Exception) { /* ignore */ }
  
  if (app == null)
  {
      app = new Excel.Application();
      app.Visible = true;
  }
  
  if (app.ActiveWindow.WindowState == Excel.XlWindowState.xlMinimized)
      app.ActiveWindow.WindowState = Excel.XlWindowState.xlNormal;
  
  wb = ...
  
  wb.Activate();
  </code></pre>
  
  <p>None of these had any effect. How can I achieve that?</p>
  
  <p>(<em>Please Note: My problem relates to the case when there</em> is <em>an existing instance, so the "Visible = true" is not necessary and <a href="https://stackoverflow.com/questions/2391589/wpf-window-stays-minimized-even-when-setting-windowstate-explicitly">this thread</a> does not apply.</em>)</p>