VB中如何实现excel表的导入?请具体写,谢谢!

cn.Open "provider=Microsoft.Jet.OLEDB.4.0;DataSource=" & fn1 & ";Extended Properties=Excel 8.0;"
执行时出现图片中的错误

挺简单的,给你一段代码
Dim I, j As Integer
Dim strSource, strDestination As String
strSource = App.Path & "\day.xls" '\data.dat"
Dim xlFile As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
On Error Resume Next
Set xlFile = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Err.Clear '如果发生错误则要清除 Err 对象。
Set xlFile = CreateObject("Excel.Application")
End If
If xlFile Is Nothing Then
MsgBox "请检查是否安装microsoft EXCELL软件"
Exit Sub
End If
Set xlWorkBook = xlFile.Workbooks.Open(App.Path & "\day.xls")
If xlWorkBook Is Nothing Then
MsgBox "程序运行出现错误"
Exit Sub
End If
Set xlSheet = xlWorkBook.Worksheets("Sheet1")
xlFile.Visible = True
xlFile.Sheets("Sheet1").Select
'将flex1中数据转到数组中,准备输出
Dim data() As String
'data数组赋值
xlSheet.Range("A7:O35").Value = data
xlSheet.Application.SaveWorkspace
xlWorkBook.Close False
xlFile.Quit
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-05-28
去网上找啊,哥N年没弄VB,早就淘汰的语言了,你所说的问题我做过
相似回答