Monday 11 June 2012

QTP - VBS - Row count of an Excel
'=========================================
' Program to display the Row count of an excel file using the VB Script
Set objExcel = CreateObject("Excel.Application")
        objExcel.Visible = True
        objExcel.DisplayAlerts = False
       
    On Error Resume Next
       
        Set objDriverExcel= objExcel.Workbooks.Open("c:\DriverFile.xlsx")
        Set objDriverMainSheet= objDriverExcel.Worksheets("MainThread")
        DriverRowCount=objDriverMainSheet.usedrange.rows.count
        Msgbox " Row Count" & DriverRowCount
    objExcel.Quit  ' Close all instence of the excel
Set objExcel = Nothing ' Relese the memory of an object
'==========================================

No comments:

Post a Comment