I have a csv file, for example with data as below (a.csv) to convert into Excel.
In the second column the leading 0s are truncated.
Is there a way to define the second column as text before importing the csv into Excel?
I dont want to append "`" or any characters to the second column as suggested in many solutions.
a.csv
--------
123,001232323
456,004567772
I have the code below.
srccsvfile = "C:\a.csv"
tgtxlsfile = "C:\a.xls"
'Instantiate Excel
Set objExcel = CreateObject("Excel.Application")
'open the CSV file
Set objWorkBook = objExcel.Workbooks.open(srccsvfile)
Set objWorksheet1 = objWorkbook.Worksheets(1)
objWorksheet1.Columns("A:I").AutoFit
objWorksheet1.Columns("B").NumberFormat="@"
'Save the file as excel workbook
objWorkBook.SaveAs tgtxlsfile, 39
'close workbook
objWorkBook.Close False
'quit excel
objExcel.Quit
'clean up
Set objWorkBook = Nothing
Set objExcel = Nothing