Forum Discussion
nnguyen_1
13 years agoContributor
I found the solution, it required manually manipulating process, but I can get rid of the constants in project suite.
Pseudo code:
'Create an Excel.Application object
Set objExcel = CreateObject("Excel.Application")
'Open the excel file
objExcel.Workbooks.Open(strExcelFilePath)
'Check if the worksheet exists
'If yes, activate it, if no, create and activate it
'Move to the last row to append data (intLastRow)
'Loop and Append data to Cells (intLastRow, column)
'Save active worksheet and close it
'Quit excel and destroy objExcel
Note: CreateObject("Excel.Application") may return errors without reason in VBScript since VBScript doesn't support Early Binding (Read more here: http://msdn.microsoft.com/en-us/library/0tcf61s1.aspx). I handled it by using On Error Resume Next.
Pseudo code:
'Create an Excel.Application object
Set objExcel = CreateObject("Excel.Application")
'Open the excel file
objExcel.Workbooks.Open(strExcelFilePath)
'Check if the worksheet exists
'If yes, activate it, if no, create and activate it
'Move to the last row to append data (intLastRow)
'Loop and Append data to Cells (intLastRow, column)
'Save active worksheet and close it
'Quit excel and destroy objExcel
Note: CreateObject("Excel.Application") may return errors without reason in VBScript since VBScript doesn't support Early Binding (Read more here: http://msdn.microsoft.com/en-us/library/0tcf61s1.aspx). I handled it by using On Error Resume Next.