帮帮忙吧,看看哪里出错了
Dim qtAppDim excelApp
Dim fos
Dim sheetNew
Dim workBook
folderpath=" E:\TestConnection"
filepath="E:\TestConnection\Conn.xls"
Set qtApp=createobject("QuickTest.Application")
qtApp.Visible=True
qtApp.Launch
Set excelApp=createobject("Excel.Application")
Set fos=createobject("Scripting.FileSystemObject")
If( fos.FolderExists (folderpath)) Then
reporter.ReportEvent micDone ,"the folder is exist","the folder is exist,please delete it"
fos.DeleteFolder folderpath
else
reporter.ReportEvent micDone,"the folder is not exist","the folder is not exist,please create it"
End If
set newfolder=fos.CreateFolder (folderpath)
If (fos.FileExists (filepath)) Then
reporter.ReportEvent micDone ,"the file is exist","the file is exist,please delete it"
fos.DeleteFile filepath
else
reporter.ReportEvent micDone,"the file is not exist","the file is not exist,please create it"
End If
set newfile=fos.CreateTextFile (filepath)
excelApp.Workbooks.Open filepath
excelApp.Workbooks.Add
Set newSheet = excelApp.Sheets.Item(1)
newSheet.Name = "Page Information"
Set conn = CreateObject("adodb.connection")
set rs = createobject("adodb.recordset")
conn.open "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=mobile;Data Source=192.168.0.111"
sql="use qtp select * from TFQ_SYS_LOG"
rs.open sql,conn
Dim i
whilenot i ( rs.eof)
Log_ID = rs("LOGID").value
Log_TIME = rs("LOGTIME").value
Log_TEXT=rs("LOGTEXT").value
Log_ISSUCCESS=rs("ISSUCCESS").value
Log_ERROR=rs("LOGERROR").value
sheetNew.Cells(i+1,1).value = Log_ID
sheetNew.Cells(i+1,2).value =Log_TIME
sheetNew.Cells(i+1,3).value =Log_TEXT
sheetNew.Cells(i+1,4).value =Log_ISSUCCESS
sheetNew.Cells(i+1,5).value=Log_ERROR
i = i + 1
rs.movenext
wend
excelObj.activeworkbook.saveas "E:\data.xls"
excelObj.quit
set excelObj = nothing
rs.close
set rs=nothing
conn.close
set conn = nothing
红色的代码部分报错了,报错信息为 sheetNew是啥?只看到前面Dim出现过,没有set过啊 sheetNew.Cells(i+1,1).value = Log_ID
>>newSheet .Cells(i+1,1).value = Log_ID 谢谢,我真是太笨了,居然写错了,两位眼睛真亮哦 我把脚本里的所有的sheetNew都改成了newSheet,可问题还是没解决,为什么呢,sheetNew
是有定义的,Set newSheet = excelApp.Sheets.Item(1)
请各位再帮我看看吧
页:
[1]