|
运行至arr(i)时报错
代码9
下标越界
请帮忙看看
Private Sub Import_Data()
Dim xPath As String
Dim i As Integer
Dim x As Integer
Dim arr() As String
Dim astr As String
Dim Eapp As Excel.Application, wb As Excel.Workbook, ws As Excel.Worksheet
xPath = Me.xlsPath.Caption
Set Eapp = CreateObject("Excel.Application")
Eapp.Visible = False
Set wb = Eapp.Workbooks.Open(xPath)
Set ws = wb.Worksheets(1)
Set dbsCurrent = CurrentDb
Set rstData = dbsCurrent.OpenRecordset("CASTER_DATA_BSL")
astr = ""
x = rstData.Fields.Count
For i = 0 To x
astr = rstData.Fields(i).Name
arr(i) = astr
Next
End Sub |
|