Save Excel File as CSV


/ Published in: Visual Basic
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Sub saveExcelAsCsv(ExcelFileName As String)
  2.  
  3. Dim objXlApp As New Excel.Application
  4. Dim objXlBook As Excel.Workbook
  5.  
  6. ' Setup the Excel Workbook to save
  7. Set objXlBook = Excel.Workbooks.Open(ExcelFileName)
  8.  
  9. ' Save the Excel file as a CSV file in a temp location
  10. objXlBook.SaveAs "c:\Windows\Temp\tmpCsvFromExcel.txt", xlCSVWindows
  11.  
  12. ' Clean up
  13. objXlBook.Close True ' Save changes
  14. objXlApp.Quit ' Close Excel
  15. Set objXlBook = Nothing
  16. Set objXlApp = Nothing
  17.  
  18. End Sub

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.