|
set ExcelApp = CreateExcel()
Set excelBook = OpenWorkbook(ExcelApp,"C:\Documents and Settings\Administrator\桌面\login.xls")
set excelSheet = GetSheet(excelBook,"Sheet1")
set strTCname = GetCellValue(excelSheet,,1,1)
到最后一步,getcellvalue的时候,报错:General run error.
下面就是cript中用到的函数
Function CreateExcel()
Dim excelSheet
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Workbooks.Add
ExcelApp.Visible = True
Set CreateExcel = ExcelApp
End Function
Function OpenWorkbook(ExcelApp, path)
On Error Resume Next
Set NewWorkbook = ExcelApp.Workbooks.Open(path)
Set OpenWorkbook = NewWorkbook
On Error GoTo 0
End Function
Function GetCellValue(excelSheet, row, column)
value = 0
Err = 0
On Error Resume Next
tempValue = excelSheet.Cells(row, column)
If Err = 0 Then
value = tempValue
Err = 0
End If
On Error GoTo 0
GetCellValue = value
End Function |
|