title: Save a file in .xlsx format in vb
body: <p>I am using the latest <code>Microsoft.Office.Interop.Excel dll</code></p>
  
  <p>The system currently saves the file in <code>.xls</code> format.<br>
  I have used the following code but I am getting an error.</p>
  
  <pre><code>App = CreateObject("Excel.Application")
  
  xlsTemplate= App.Workbooks.Open(TemplateFile) ' template is in .xls format
  
  TargetPath = Some target path.xlsx
  
  Excel.Workbook.SaveCopyAs(TargetPath)
  
  Excel.Workbook = App.Workbooks.Open(TargetPath) ' code breaks here
  
  SomeFunction(Excel.Workbook)
  
  ExcelBook.SaveAs(ExcelBook.FullName,   Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook,  System.Reflection.Missing.Value, System.Reflection.Missing.Value, False, False, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlUserResolution, True, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value)
  ExcelBook.Saved = True
  </code></pre>
  
  <blockquote>
    <p>Error:Excel cannot open the file '.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.</p>
  </blockquote>