How to convert xls to CSV on

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to convert xls to CSV on
(Comstock Images/Comstock/Getty Images)

Microsoft Excel is a spreadsheet application that is part of the Microsoft Office suite. Visual Basic.NET is a Microsoft programming language that’s relatively easy to learn and use. A Comma-Separated Value (CSV) file is a plain text file that can be easily read by other applications. A CSV file is also used to save hard drive space since it’s much smaller in size than a normal XLS file. In a few simple steps, you can convert XLS files to CSV files using VB.NET.

Skill level:


  1. 1

    Start “Microsoft Visual Basic 2008 Express." Select the “File” menu, then click “New Project…” Click “Windows Forms Application” under “Visual Studio installed templates.” Select “OK."

  2. 2

    Press “Ctrl," "Alt," and "X” to open the “Toolbox." Double-click “Button” under “Common Controls” to add a new button to “Form 1."

  3. 3

    Click “Project,” then select “Add Reference." Click “COM," select “Microsoft Excel 12.0 Object Library” and click “OK."

  4. 4

    Double-click “Button 1” to open the “Form1.vb” module. Type the following at the very top of “Form1.vb” to add a reference:

    Imports Microsoft.Office.Interop

  5. 5

    Type the following to declare your variables inside "Sub Button1_Click":

    Dim excel Application As New Excel.Application Dim excelWrkBook As Excel.Workbook

  6. 6

    Type “excelApplication.Visible = False” to hide Excel. Type “excelApplication.DisplayAlerts = False” to disable displaying message alerts.

  7. 7

    Type the following to open your "XLS" workbook and save it as "CSV":

    excelWrkBook = excelApplication.Workbooks.Open("C:\myWorkbook.xls") excelWrkBook.SaveAs(Filename:="c:\myWorkbookCSV.csv", _ FileFormat:=Microsoft.Office.Interop.Excel.XlFileFormat.xlCSV)

    When you run your program and click ”Button 1,” this code will execute to convert your file.

  8. 8

    Type the following to close and quit your application:

    excelWrkBook.Close() excelApplication.DisplayAlerts = True excelApplication.Quit()

  9. 9

    Press "F5" to execute your program. Click "Button1."

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.