|
'1.对EXCEL文件进行写操作
Option Explicit
Dim fso, ddFilePath, i
Dim ExcelBook, ExcelSheet
'ddFilePath = Environment.Value("TestDir") & "\ddd.xls"
ddFilePath = Environment.Value("TestDir")&"\ddd.xls"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(ddFilePath) Then
fso.DeleteFile(ddFilePath)
End If
wait 3
Set ExcelBook = CreateObject("Excel.Application")
Set ExcelSheet = CreateObject("Excel.Sheet")
ExcelSheet.Application.visible = False
ExcelSheet.ActiveSheet.Cells(1,1).Value = "Agent Name"
ExcelSheet.ActiveSheet.Cells(1,2).Value = "Password"
ExcelSheet.ActiveSheet.Cells(1,3).Value = "Expire Value"
ExcelSheet.ActiveSheet.Cells(1,4).Value = "Fact Value"
ExcelSheet.ActiveSheet.Cells(1,5).Value = "Execute Result"
ExcelSheet.ActiveSheet.Cells(2,1).Value = "ad"
ExcelSheet.ActiveSheet.Cells(2,2).Value = "Mercury\"
ExcelSheet.ActiveSheet.Cells(2,3).Value = "Agent name must be at least 4 characters long."
ExcelSheet.ActiveSheet.Cells(3,1).Value = "Admin"
ExcelSheet.ActiveSheet.Cells(3,2).Value = "Merc"
ExcelSheet.ActiveSheet.Cells(3,3).Value = "Incorrect password. Please try again"
ExcelSheet.ActiveSheet.Cells(4,1).Value = "Admin"
ExcelSheet.ActiveSheet.Cells(4,2).Value = "Mercury"
ExcelSheet.ActiveSheet.Cells(4,3).Value = "Flight Reservation"
ExcelSheet.SaveAs ddFilePath
ExcelBook.Quit
Set ExcelBook = Nothing
这个我再网路上看到的代码,没有任何修改代码,我仅对QTP的TOOLS下的FORLDS的路径添加了,然后在目录下加入了一个ddd.xls而已,运行完毕,打开DDD,没有写入任何数据?
这个是为什么呢????
看到这个代码是数据的写入操作,为什么都没数据被写入呢???懂的达人来讲解下这个代码,谢谢 |
|