Subscript out of range怎么解决
代码如下想读取excel文件的内容arrRange = ReadFile("C:\Documents and Settings\XPMUser\Desktop\input.xlsx","Tree")
Msgbox arrRange(3,1)
Function ReadFile(sFileName,sSheetName)
Dim oExcel
Dim oSheet
Dim oRange
Dim arrRange
On Error Resume Next
Set oExcel = CreateObject("Excel.Application")
If err.Number <> 0 Then
MsgBox "cant find Excel" & vbCrLf & _
"make sure Excel file correct", vbCritical
Exit Function
End If
On Error Goto 0
On Error Resume Next
oExcel.Workbooks.Open(sFileName)
If err.Number <> 0 Then
MsgBox "cant iniliaze Excel " & vbCrLf & _
"make sure Exce", vbCritical
Exit Function
End If
On Error Goto 0
Set oSheet = oExcel.Worksheets(sSheetName).UsedRange
Set oRange = oSheet.Range("A1:Z10")
arrRange = oRange.Value
oExcel.WorkBooks.Item(1).Close
oExcel.Quit
Set oExcel = Nothing
Subscript out of range
ReadFile = arrRange
End Function
运行提示Subscript out of range
Subscript out of range
Subscript out of range 数组下标越界,楼主好好检查一下 好的谢谢了 没看明白是为什么... 本帖最后由 lanchozxd 于 2011-4-19 16:40 编辑
为啥倒数第三行会有:Subscript out of range 呢?而且还不是注释
页:
[1]