title: Powershell excel refresh fails with "Call Was Rejected by Callee" when .visible=$false
body: <p>I've had this issue for a long time now and had just ignored it out of laziness, however I now need to find a solution. I have a script which automates refreshing a large number of excel documents. This works well and dandy, however, it fails if I have the Visible property set to false on workbooks which are stored on a network share. </p>
  
  <p>To reiterate, refreshing with the visible property set to false works fine on LOCAL files, but any workbook saved on a \ location fails with an error "Call was rejected by callee". All refreshes work fine with the visible property set to true. </p>
  
  <p>Here is my code : </p>
  
  <pre class="lang-psh prettyprint-override"><code>#Create Excel COM object and set it up for use.
  $excel = new-object -comobject Excel.Application;
  $excel.DisplayAlerts = $false;
  #If this is set to false, saving the file on a network share will fail. Reason : Unknown.
  $excel.Visible = $true;
  #Open workbook which should be refreshed. 
  $excelworkbook = $excel.workbooks.Open($workbook);
  #Refresh WB
  $excelworkbook.RefreshAll();
  #Save
  $excelworkbook.Save();
  #Quit Excel
  $excel.Quit();
  #Destroy COM object. (VERY IMPORTANT!!!!!)
  [System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel);
  </code></pre>
  
  <p>I have tried the following :</p>
  
  <ol>
  <li>Adding Start-Sleep 30 between creating the excel object and setting the visible property</li>
  <li>Setting visible before DisplayAlerts</li>
  <li>Wishing really hard for it to just work</li>
  </ol>
  
  <p>Any ideas?</p>