Forum Discussion
shankar_r
9 years agoCommunity Hero
Hi,
- You don't really need to have Delay between Creating object and opening an excel workbook
- You can switch between sheets using WorkBook.Sheets.Item("<Sheet name>");
For Ex:
I have modified your code
function WriteExcel(Record)
{
var Excel,row, column, x,sheetObj,wrkbookObj;
x=Record+1;
Excel = Sys.OleObject("Excel.Application");
//Delay (3000);
wrkbookObj = Excel.Workbooks.Open("C:\\Users\\...DATA TABLE IDs.xls");
sheetObj = wrkbookObj.Sheets.Item("Sheet1");
sheetObj.Cells.Item(x,1).Value=Record;
sheetObj.Cells.Item(x,2).Value=ProjectSuite.Variables.VAR1;
sheetObj = wrkbookObj.Sheets.Item("Sheet2");
sheetObj.Cells.Item(x,6).Value=aqDateTime.Today();
wrkbookObj.Save();
Excel.Quit();
}
CS
9 years agoNew Contributor
Thanks Shankar!