title: how to use excel vba to Opening a .csv and saving it as .xlsx
body: <p>I am using MS Access form to open an .csv file using choose file.</p>
  
  <pre><code>Private Sub Import_Click()
  Dim ExcelApp
  Set ExcelApp = CreateObject("Excel.Application")
  ExcelApp.Workbooks.Open (Me.txtCSVFIle.Value)
  
  ExcelApp.DisplayAlerts = False
  ExcelApp.ActiveWorkbook.SaveAs FileName:=Me.txtCSVFIle.Value, FileFormat:=51
  ExcelApp.Visible = False
  
  ExcelApp.ActiveWorkbook.close False
  ExcelApp.Quit
  End Sub
  </code></pre>
  
  <p>the value of Me.txtCSVFIle.Value would be "I:\csv files\20140228_ExtStats.csv"</p>
  
  <p>Now the problem is my save as command is saving it as it's name with .csv. How can i remove the .csv so that my next statement FileFormat:=51 make it save to .xlsx?</p>
  
  <p>*Ps: the Displayalerts is set to false to prevent user to be confuse.</p>
  
  <p>Expected result should be save as "I:\csv files\20140228_ExtStats.xlsx". </p>