51Testing软件测试论坛

标题: 帮帮忙吧,看看哪里出错了 [打印本页]

作者: 158403991    时间: 2009-12-29 17:52
标题: 帮帮忙吧,看看哪里出错了
Dim qtApp
Dim 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 = "age Information"
Set conn = CreateObject("adodb.connection")
set rs = createobject("adodb.recordset")
conn.open "rovider=SQLOLEDB.1assword=saersist 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
while  not 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
红色的代码部分报错了,报错信息为[attach]58541[/attach]
作者: May_may    时间: 2009-12-29 17:58
sheetNew是啥?只看到前面Dim出现过,没有set过啊
作者: lantianwei    时间: 2009-12-29 17:59
sheetNew.Cells(i+1,1).value = Log_ID 
>>newSheet .Cells(i+1,1).value = Log_ID 
作者: 158403991    时间: 2009-12-30 14:07
谢谢,我真是太笨了,居然写错了,两位眼睛真亮哦
作者: 158403991    时间: 2009-12-30 14:17
我把脚本里的所有的sheetNew都改成了newSheet,可问题还是没解决,为什么呢,sheetNew
是有定义的,Set newSheet = excelApp.Sheets.Item(1)
请各位再帮我看看吧




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2