|
脚本如下:
运行到QTP_read_Excel(pathway,sheetname,x,y)的时候,提示 could not find the file,实际上是可以找到的,因为我单独运行任何一个关于excel的function都成功,请问改怎么处理
call driver()
call QTP_read_Excel(pathway,sheetname,x,y)
call QTP_RowCount_Excel(pathway,sheetname)
'++++++++++++++driver()++++++++++++++
public function driver()
dim QtApp
dim Status
dim caseName
dim x,oRowCount
set QtApp=createobject("QuickTest.Application")
QtApp.launch
QtApp.visible=true
oRowCount=QTP_RowCount_Excel("E:\DailyWork\2011\08\UMASSScript\Data\Control.xls","PersonDetails")
wscript.sleep(20)
for x=1 to oRowCount
'Call QTP_read_Excel("E:\Control.xls","PersonDetails",x,1)
Status=QTP_read_Excel("E:\DailyWork\2011\08\UMASSScript\Data\Control.xls","PersonDetails",x,1)
If Status="Y" Then
caseName=Status=QTP_read_Excel("E:\DailyWork\2011\08\UMASSScript\Data\Control.xls","PersonDetails",x,4)
QtApp.open caseName
QtApp.Test.Run ,true
QtApp.Test.Close
end if
next
QtApp.quit
set QtApp=Nothing
end function
'++++++++++++++++++++++++QTP_read_Excel(pathway,sheetname,x,y)++++++++++++++
Public Function QTP_read_Excel(pathway,sheetname,x,y)
Dim oExcel,oWorkBook,ovalue
set oExcel=createobject("Excel.application")
oExcel.Visible=false
Set oWorkBook=oExcel.Workbooks.Open(pathway)
oWorkBook.worksheets(sheetname).activate
ovalue=oWorkBook.worksheets(sheetname).cells(x,y).value
oExcel.Workbooks.Close
QTP_read_Excel=ovalue
set oWorkbook=nothing
set oExcel=nothing
End function
'++++++++++++++++++++++++QTP_RowCount_Excel(pathway,sheetname)++++++++++++++
public function QTP_RowCount_Excel(pathway,sheetname)
dim oExcel,oWorkbook,oSheet,oRowCount
set oExcel=createobject("Excel.application")
set oWorkbook=oExcel.workbooks.open(pathway)//这里提示找不到pathway
set oSheet=oWorkbook.Sheets(sheetname)
oRowCount=oSheet.usedrange.rows.count
oWorkbook.Save
oExcel.Workbooks.Close
oExcel.quit
QTP_RowCount_Excel=oRowCount
set oSheet=Nothing
set oWorkbook=nothing
set oExcel=nothing
end function |
|