title: "Unable to set the FreezePanes property of the Window class" Excel 2016 (office 365)
body: <p>I've build an excel addin which fills a worksheet with data from a database. I also add some styling and lock some rows and columns by using FreezePanes. </p>
  
  <pre><code>worksheet.Activate();
  worksheet.Application.ActiveWindow.FreezePanes = false;
  worksheet.Application.ActiveWindow.SplitRow = 4;
  worksheet.Application.ActiveWindow.SplitColumn = 11;
  worksheet.Application.ActiveWindow.FreezePanes = true;
  </code></pre>
  
  <p>This all worked like a charm in excel 2010/2013 but I recently switched to excel 2016 (office 365) and from then on I had problems with the FreezePanes when my excel worksheet is not on the foreground. I searched the internet and the only thing I come across is that I can only preform a FreezePanes on an active sheet, I knew that - I allready do activate the sheet before setting the FreezePanes. This worked in excel 2010, even though physically my excel wasn't sent to the foreground.</p>
  
  <p>Excel from the office 365 probably really want my excel worksheet to be physically in the foreground but <code>worksheet.Activate()</code> doesn't help and I also tried the following code:</p>
  
  <pre><code>[DllImport("user32.dll")]
  [return: MarshalAs(UnmanagedType.Bool)]
  static extern bool SetForegroundWindow(IntPtr hWnd);    
  
  [DllImport("user32.dll", SetLastError = true)]
  static extern System.IntPtr FindWindow(string lpClassName, string lpWindowName); 
  
  string caption = oExcel.Caption;
  IntPtr handler = FindWindow(null, caption);
  SetForegroundWindow(handler);
  </code></pre>
  
  <p>But this too didn't work. Can any body help me with this one?</p>
  
  <p>To be clear: The version of my excel is 2016 Version 1611 (Build 7571.2109) </p>