title: Excel workbooks.saveas() error in powershell
body: <p>I'm trying to convert .xls files to .xlxs 
  I tried many variations of this code but every time i'm facing this error message :</p>
  
  <blockquote>
    <p>Exception lors de l'appel de « SaveAs » avec « 2 » argument(s) : « La
    méthode SaveAs de la classe Workbook a échoué. »    Au caractère
    C:\temp\xlsx.ps1:18 : 6                                    </p>
    
    <ul>
    <li>try{$opendoc.saveas($basename, $saveFormat)}                                                                       </li>
    <li>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
    <ul>
    <li>CategoryInfo          : NotSpecified: (:) [], MethodInvocationException                                            </li>
    <li>FullyQualifiedErrorId : ComMethodTargetInvocation</li>
    </ul></li>
    </ul>
  </blockquote>
  
  <p>Here is my code :</p>
  
  <pre><code>$excel = new-object -comobject excel.application
  $excel.Visible = $false
  $saveFormat = "xlOpenXMLWorkbook";
  
  ls c:\temp\*.xls | %{
      $opendoc = $excel.workbooks.open($_.FullName)
      $excel.DisplayAlerts =$false 
      $basename = $_.basename
      try{
          $opendoc.saveas($basename,$saveFormat,$null,$null,$false,$false,"xlNoChange","xlLocalSessionChanges")
        # tried this one and got same error : $opendoc.saveas($basename, $saveFormat)}
      }
      catch{
          $opendoc.close();$excel.quit()
          $_ 
      }
      $opendoc.close();   
  }
  
  $excel.quit()    
  </code></pre>
  
  <p>do you know the working recipe please ?                                       </p>