02-28-2010, 06:42 PM
u have written function correctly but you just forgot to call it in your code thats the reason its not working..
i have added call to your function CreateExceFile() .. now its working ..
happy scripting
CreateExceFile()
i have added call to your function CreateExceFile() .. now its working ..
happy scripting
CreateExceFile()
Code:
public strFullPath
strFullPath="D:\SST 1C\Results\Accommodation\Results.xls"
CreateExceFile()
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