|
我有一个vbs代码如下:
Public Function readExcel(rowno)
Dim xlApp,xlWorkBook,xlSheet
Dim iColumnCount,iLoop,numAdd
Set xlApp= CreateObject("Excel.Application")
xlApp.Visible= True
Set xlWorkBook= xlApp.Workbooks.Open("c:\data.xls")
Set xlSheet= xlWorkBook.Sheets("Sheet1")
iColumnCount = ActiveSheet.UsedRange.Columns.Count
If iColumnCount <> Null Then
For iLoop= 1 To iColumnCount
numAdd= xlSheet.Cells(RowNo,iLoop)
Next
xlWorkBook.Save
xlWorkBook.Close
xlApp.Quit
Set xlSheet= Nothing
Set xlWorkBook= Nothing
Set xlApp= Nothing
readExcel=numAdd
Else
MsgBox "iColumnCount is null!"
End If
End Function
我在QTP中取其返回值的代码如下:
ExecuteFile "C:\common.vbs"
Dim rowno ,res
rowno = 1
res = readExcel rowno
但是QTP在res = readExcel rowno处老报语句未结束的错误,请教怎么回事? |
|