Forum Discussion
Hi Frank,
If you use JavaScript (not JScript), you need to use .Item to access collection items in COM objects.
var xlsheet = excel.ActiveWorkBook.WorkSheets.Item(sheetname);
- tristaanogre8 years agoEsteemed Contributor
HKosova wrote:
Hi Frank,
In JavaScript (unlike JScript), you need to use .Item to access collection items in COM objects.
var xlsheet = excel.ActiveWorkBook.WorkSheets.Item(sheetname);
JavaScript - Specifics of Usage: Accessing Collection Items
Ah, yes... there is that... however, he's using the same code in a different location so I'm thinking this is JScript and not JavaScript... but certainly worth the try...
- frank_vanderstr8 years agoContributor
Using .Item seemed to do the trick.
Next problem I am facing now is that using that pathway, I do not have access to the Cells function for the worksheet as shown in my code here where I populate my array with the data found in the given row of the worksheet.
for(var colcounter = column; colcounter <= colend; colcounter ++) {
var testcell = VarToStr(xlsheet.Cells(row, colcounter).Value);rowdata[arraycounter] = testcell;
arraycounter +=1;
}Using the Item object does it have a similar function to get cell data?
- HKosova8 years agoSmartBear Alumni (Retired)
Well, Cells is also a collection so you also need .Item.
Also, Object Browser shows that Value requires a range parameter, so you might want to use Value2 instead (at least if you use Excel 2010 like me).
var testcell = VarToStr(xlsheet.Cells.Item(row, colcounter).Value2);
Related Content
- 5 years ago
- 13 years ago
- 2 years ago
Recent Discussions
- 5 hours ago
- 23 hours ago
- 2 days ago