firemad1234 发表于 2015-4-7 17:25:39

qtp使用求助

各位自动化测试大虾,请问假设我导入一个excel(此excel包含用户ID和密码,目的是做账户登录)
Dim epath,i,UserName,PhoneNumber,BankCard,ID
epath="C:\Users\Administrator\Desktop\中登客户账户建立\Account builder.xls"
DataTable.ImportSheet epath,"Sheet1","客户账户创建"       

假设excel账户中有存有错误此账户无法登陆,就需要将他记录在excel sheet2中?请问这时应该如何处理,我使用:
Function record(epath,i)
Set xfile=createobject("Excel.Application")
Set xwork=xfile.workbooks.
Set xsheet=xwork.sheets("sheet2")
recon=datatable.LocalSheet.GetRowCount
        datatable.LocalSheet.SetCurrentRow(i)
        content=datatable.Value("Name","客户账户创建")
        xsheet.cells(i,1)=content
        xwork.save
        xwork.close
Set xfile=nothing
Set xwork=nothing
Set xsheet=nothing
End Function
但是import的时候excel是已经占用状态,无法调用,请问应该如何处理谢谢!

土土的豆豆 发表于 2015-4-8 13:45:46

你如何判断账号/密码不正确的?
看你代码似乎直接就写入而已?
xwork.Close?
xsheet.Quit?
试试看
页: [1]
查看完整版本: qtp使用求助