Hi,
I have this csv file saved on the c drive as item.csv below is contents of the csv file:
Item Report,,,
id,merchant_date,item_id,a
mount
20070612005814,2007-06-12,
1815918227
9601760430
16,65.00
20070612005814,2007-06-12,
1815919623
7101760430
16,182.34
20070612005814,2007-06-12,
1815931096
7101760430
16,25.00
When you open the csv file in Notepad it looks fine,however, when opened with Excel the "id" column and "item_id" column display with a scientific notation. I need a VBScript to convert these two columns in a format that is the original view and saved as an excel file. I have tried a bunch of things but am at a loss, below is the script I have been playing with.
'*************************
**********
**********
*********
Option Explicit
Dim fldr, f, file,strOrigFile, strFile, fso, strDirectory
Dim objExcel
strOrigFile = "c:\items.csv"
'*************************
**********
**********
*********
'CONVERTS THE FILE TO AN EXCEL FILE
'*************************
**********
**********
*********
strFile = replace(strOrigFile,".csv"
,".xls")
Set objExcel = CreateObject("Excel.Applic
ation")
objExcel.Workbooks.Open strOrigFile
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.Sa
veAs strFile, -4143
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.Cl
ose
objExcel.DisplayAlerts = False
objExcel.Application.Quit
'*************************
**********
**********
*********
'FORMAT THE EXCEL FILE AND SAVE IT
'*************************
**********
**********
*********
objExcel.Workbooks.Open strFile
objExcel.columns("A:A").nu
mberformat
="0"
objExcel.columns("C:C").nu
mberformat
="0"
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.Sa
veAs strFile, -4143
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.Cl
ose
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing
msgbox "FINISHED!!!"
'*************************
**********
**********
*********
Now the "id" column looks good but the "item_id" puts all zero's after the 15th digit. I'm not sure how to convert this csv file to excel so that it displays correctly in Excel.
Start Free Trial