我借用论坛的程序修改后执行如下程序段,却出现了异常错误,测试了N多次,就是通不过,请蓝老师或狐友给与帮助,谢谢!
DataTables("ProductionIssue").StopRedraw
Dim App As New MSExcel.Application
Try
Dim fpf As String = "P:\General documents\Worktime Data\Fox Data\Query\aa.xlsx"
'Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(dlg.FileName)
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fpf)
MessageBox.Show(1)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(0)
Dim Rg As MSExcel.Range = Ws.UsedRange
Dim ary = rg.value
MessageBox.Show(2)
For n As Integer = 2 To rg.Rows.Count
Dim ro As Row = Tables("ProductionIssue").AddNew
For i As Integer = 0 To Tables("ProductionIssue").Cols.Count - 1
ro(i) = ary(n, i + 2)
If i < 5 Then
MessageBox.Show(ro(i))
End If
Next
Next
MessageBox.Show("导入成功!", "恭喜!")
Catch ex As exception
msgbox(ex.message)
MessageBox.Show("导入失败!", "恭喜!")
Finally
DataTables("ProductionIssue").ResumeRedraw
app.quit
End Try
程序执行到“ Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(0)” 时出现如下错误提示
[此贴子已经被作者于2023/8/4 18:05:16编辑过]