How to open Exceel sheet using QTP script?

Showing Answers 1 - 3 of 3 Answers

Suresh Babu Lingam

  • Nov 14th, 2006
 

Hi,

you can open Excel in QTP by using the following command.

SystemUtil.Run"path of the file"

Cheers

Suresh Babu.L

  Was this answer useful?  Yes

Suresh Babu Lingam

  • Nov 14th, 2006
 

Hi,

To open Excel in QTP following is the Script

SystemUtil.Run"c:Document and settingDesktopxyz.xls"

Cheers

Suresh Babu.L

  Was this answer useful?  Yes

wbe8st

  • Nov 14th, 2006
 

Hi,

do you want to open your Excel sheet as a database?

here we go:

Filename = "c:x.xls"
MyWorkSheet = "[test$]" 'special syntax, sheet name is test

ActiveCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
ActiveCon = ActiveCon & Filename
ActiveCon = ActiveCon & ";Extended Properties=""Excel 8.0;HDR=NO;IMEX=1;"""
    
set rsExcel = CreateObject("ADODB.Recordset")
rsExcel.LockType = 1
rsExcel.ActiveConnection = ActiveCon

rsExcel.Open "Select * from " & MyWorkSheet

msg = ""

for j = 0 to rsExcel.fields.count -1
 msg = msg & rsExcel.fields(j).name & "   "
next
msg = msg & vbcrlf
msg = msg & vbcrlf

do while not rsExcel.eof
for j = 0 to rsExcel.fields.count -1
 msg = msg &  rsExcel.fields(j) & "   "
next
msg = msg & vbcrlf
rsExcel.movenext
loop
rsExcel.close

msgbox msg

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions