10-22-2009, 08:32 PM
Hi all
I am running csv to excel conversion code in QTP9.5 , the execution and results are fune except that some of the "date" field data in CSV is converted to "numbers" in excel.
Any comments or help is appreciated.
Many thanks in advance
below is the code I am using
'Function Name : CSV to excel
'Fucntion Description: 'VBScript to convert CSV file to Excel - number format issue
'Test data used : test data
'Date : 21/04/09
'Written by :
'*******************************************************************
'******************************************************
'CONVERTS THE FILE TO AN EXCEL FILE
'******************************************************
'******************************************************
'FORMAT THE EXCEL FILE AND SAVE IT
'******************************************************
I am running csv to excel conversion code in QTP9.5 , the execution and results are fune except that some of the "date" field data in CSV is converted to "numbers" in excel.
Any comments or help is appreciated.
Many thanks in advance
below is the code I am using
'Function Name : CSV to excel
'Fucntion Description: 'VBScript to convert CSV file to Excel - number format issue
'Test data used : test data
'Date : 21/04/09
'Written by :
'*******************************************************************
Code:
Function csvtoexcel
Dim fldr, f, file,strOrigFile, strFile, fso, strDirectory
Dim objExcel
strOrigFile = "C:\QTPV6\results\actual\200906019043a.csv"
'CONVERTS THE FILE TO AN EXCEL FILE
'******************************************************
Code:
strFile = replace(strOrigFile,".csv",".xls")
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open strOrigFile
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.SaveAs strFile, -4143
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.Close
objExcel.DisplayAlerts = False
objExcel.Application.Quit
'******************************************************
'FORMAT THE EXCEL FILE AND SAVE IT
'******************************************************
Code:
objExcel.Workbooks.Open strFile
objExcel.columns("A:A").numberformat="0"
objExcel.columns("C:C").numberformat="0"
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.SaveAs strFile, -4143
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.Close
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing
End Function