02-28-2010, 01:13 AM
Hi Anyone Help to me how to write the code for creating excel sheet.
I have installed in MS excel 2007.
I am trying the below code and run through QTP. But excel sheet is not created the particular path
I have installed in MS excel 2007.
I am trying the below code and run through QTP. But excel sheet is not created the particular path
Code:
public strFullPath
strFullPath="D:\SST 1C\Results\Accommodation\Results.xls"
Function CreateExceFile()
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(strFullPath)) Then
Set objExcelApplication = CreateObject("Excel.Application")
objExcelApplication.Workbooks.open(strFullPath)
Else
Set objExcelApplication = CreateObject("Excel.Application")
objExcelApplication.Visible = true
objExcelApplication.Workbooks.Add
objExcelApplication.ActiveWorkbook.SaveAs strFullPath
End If
Set objResultSheet = objExcelApplication.ActiveWorkbook.Worksheets(1)
objResultSheet.Name = "Results"
objExcelApplication.ActiveWorkbook.Save
objExcelApplication.Workbooks.Close
objExcelApplication.Quit
Set objExcelApplication = Nothing
End Function