笨笨小七 发表于 2011-10-24 10:02:37

excel导入excel老是出错,请大家帮我看看!!!!!谢谢

DataStr= "G:\data.xls"
Set ExlObj=CreateObject("Excel.Application")
ExlObj.Visible = false
ExlObj.DisplayAlerts = false

Set book=ExlObj.Workbooks.Open(DataStr)
Set sheet=book.Worksheets("Sheet1")

For i=2 to sheet.usedrange.rows.count
systemutil.Run "G:\program files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
UserName=ExlObj.WorkSheets("Sheet1").Cells(i,1)
PassWord=ExlObj.WorkSheets("Sheet1").Cells(i,2)
Dialog("Login").WinEdit("Agent Name:").Set UserName
Dialog("Login").WinEdit("Password:").SetSecure PassWord
    wait 1
Dialog("Login").WinButton("Cancel").Click

Next
ExlObj.Quit
Set ExlObj = nothing

根据网上查找的代码自己稍微改了下路劲,但是老是报错
cannot find the “Agent Name:”object's parent "login"(class dialog)Verify that parent properties match an object currently displayed in your application
"cancel"也是这样的原因,谁能告诉我错误怎么改,整个从excel中输入用户名和密码怎么实现,并吧输出结果导出拉,谢谢拉

wangyanzhao 发表于 2011-10-25 09:17:19

ExlObj.Visible = false
ExlObj.DisplayAlerts = false
把上面都设置为TRUE;试下

efficient 发表于 2011-10-25 13:55:11

提示很明显了: cannot find the “Agent Name:”,找不到“Agent Name:”这个对象,叫你确认一下 父对象 "login" 。 不关excel的问题

笨笨小七 发表于 2011-10-25 18:18:29

回复 3# efficient


    我已经添加了对象了,还是出现这个错误,我自己再琢磨琢磨
页: [1]
查看完整版本: excel导入excel老是出错,请大家帮我看看!!!!!谢谢