Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to handle opening an excel during run time?
#1
Solved: 11 Years, 4 Months ago
Hi,

Below is the scenario:

I have to open an excel file from the application during run time. And I have to get the record count from that excel sheet.
It is taking more seconds to open the excel sheet when data is more.

Used below code but did not work:

Code:
Public Function Export_Debug()
    
Browser("X").Dialog("File Download").WinButton("Open").Click

Do
   Wait(2)
   On Error Resume Next
   Set objExcel = Getobject(,"Excel.Application")
Loop Until objExcel.Visible = True

rowCount = objExcel.ActiveWorkbook.ActiveSheet.usedrange.rows.count
Reporter.ReportEvent micDone, "Record Count in Excel", "Record Count is: " & rowCount

objExcel.Quit
End Function

Can anyone help me with solution?

Thanks,
Ravi.
Reply
#2
Solved: 11 Years, 4 Months ago
I have an alternative solution.
Try doing this.
use datatable.importsheet "<Path of xlx file> and then
count number of rows of the data table
Reply
#3
Solved: 11 Years, 4 Months ago
Hi,

Try to use the below code

Code:
strFileName="C:\Documents and Settings\qtp\Desktop\Login_Details.xls"
strSQLStatement="Select * from [Dummy$]'"

Dim objAdCon, objAdRs
Set objAdCon = CreateObject("ADODB.Connection")
objAdCon.Open "DRIVER={Microsoft Excel Driver (*.xls)};DBQ="&strFileName &";Readonly=True"

Set objAdRs = CreateObject("ADODB.Recordset")
objAdRs.Open strSQLStatement, objAdCon,3
MsgBox objAdRs.RecordCount

Regards,
RP
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Can UFT Handle Detecting Redirects? zunebuggy 0 901 05-28-2020, 06:50 PM
Last Post: zunebuggy
  QTP not recogonising object during run time Lavanya N 2 3,727 10-28-2015, 12:46 PM
Last Post: vinod123
  Writing to Run time data table Neetha 5 12,175 08-27-2015, 10:18 AM
Last Post: supputuri
  Error while opening test run results vkalyankar 3 4,318 11-12-2014, 09:49 AM
Last Post: vinod123
  QTP Stuck at Opening stage TurtleRock 4 3,680 05-27-2014, 08:42 PM
Last Post: mauler69

Forum Jump:


Users browsing this thread: 1 Guest(s)