For i = 0 to run_count - 1
' 第一次执行时,在Ex cel文件中写入标题
If i = 0 Then
WriteExcelCell excelfile, excelsheet, 1, 1, "登录次数"
WriteExcelCell excelfile, excelsheet, 1, 2, "所耗时间"
End If
c = i + 1
' 向Excel文件写入此次执行的登录次数、所耗时间
WriteExcelCell excelfile, excelsheet, c + 1, 1, c
WriteExcelCell excelfile, excelsheet, c + 1, 2, MercuryTimers("Login_Time").ElapsedTime
' 等待3秒,让应用程序完全关闭
wait 3
' 再启动应用程序
If i <> run_count - 1 Then
SystemUtil.run exefile
End If
Next
'******************************************************************************************************************************************
' 公共函数部分
'******************************************************************************************************************************************
' 往Excel文件指定页面、单元写入内容
public Function WriteExcelCell (filename, sheetname, x, y, cellvalue)
Dim srcData,srcDoc,ret, fso
Set fso = CreateObject("Scripting.FileSystemObject")
' 文件不存在时创建文件
If not fso.FileExists(filename) Then
CreateExcelFile excelfile, excelsheet
End If
Set srcData = CreateObject("Excel.Application")
srcData.Visible=false
Set srcDoc= srcData.Workbooks.Open(filename)
srcDoc.Worksheets(sheetname).Activate
srcDoc.Worksheets(sheetname).cells(x,y)= cellvalue
srcDoc.save
srcDoc.Close
Set srcData = Nothing
Set srcDoc = Nothing
End Function
' 创建指定的Excel文件
Public Function CreateExcelFile(filename, sheetname)
Set ExcelObj = CreateObject("Excel.Application")
ExcelObj.Workbooks.Add
Set NewSheet = ExcelObj.Sheets.Item(1)
NewSheet.Name = sheetname
ExcelObj.ActiveWorkbook.SaveAs filename
ExcelObj.Quit
End Function作者: 云层 时间: 2012-8-29 08:45
给具体的错误信息