Forum Discussion

TanIlak's avatar
TanIlak
Contributor
2 years ago

Excel

Hi Team!!!

 

The excel file is opened was not closed properly because of this the last opened excel only opening if changed the sheet name I have closed that excel also

Still its not fetching the proper Sheet name

>>Let me know whats the problem

>>Here the code

function Excel()
{
  let Excel = getActiveXObject("Excel.Application");

  Excel.Visible=true;
  Excel.Workbooks.Open("C:\\MyFile.xlsx");
  Excel.ActiveWorkBook.WorkSheets.Item("Sheet4");
  let RowCount = Excel.ActiveSheet.UsedRange.Rows.Count;
  let ColumnCount = Excel.ActiveSheet.UsedRange.Columns.Count;
  for (let i = 1; i <= RowCount; i++)
  {
   let s = "";
   for (let j = 1; j <= ColumnCount; j++)
   s = (VarToString(Excel.Cells.Item(i, j)));

        [......Some Scripts.......]
  }
  Excel.Quit;
}

 

 

 

Thanks in Advance