Pages

Wednesday, March 2

Count number of rows in Excel without opening it.


'Following code demonstrate how to count number of rows in Excel without opening it - using vbscipt in QTP.

Set objExcel=CreateObject("Excel.Application")
Set objWB=objExcel.WorkBooks.Open("C:\abc.xls")
Set objSheet=objWB.WorkSheets(1)
msgbox objSheet.usedrange.rows.count
Set objExcel=Nothing