Posted By

corydeppen on 03/27/07


Tagged

excel access vba 2003 vb


Versions (?)

Save Excel File as CSV


 / Published in: Visual Basic
 

  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  

You need to login to post a comment.