标题: 求教:如何把多个excel表导入导一个access表中 [打印本页] 作者: happylirui 时间: 2009-1-13 11:34 标题: 求教:如何把多个excel表导入导一个access表中 导入一个我会,但是导第二个excel表的时候,就弹出“不能导入”的窗口,是什么原因?作者: Henry D. Sy 时间: 2009-1-13 12:12
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim strName As String
Dim i As Integer
For i = 1 To 3 '假设你有三个xls文件
strName = CurrentProject.Path & "\book" & i & ".xls"
Set xlBook = xlApp.Workbooks.Open(strName)
DoCmd.TransferSpreadsheet acImport, , "Q", strName
xlBook.Close
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing
Next
[ 本帖最后由 Henry D. Sy 于 2009-1-13 12:14 编辑 ]作者: happylirui 时间: 2009-1-13 12:20
这么复杂啊,没有向导之类简单的吗?作者: todaynew 时间: 2009-1-13 14:04
insert into myAccessTable
select * from [EXCEL 8.0;DATABASE=C:\info.XLS].[sheet1]
union all
select * from [EXCEL 8.0;DATABASE=C:\info.XLS].[sheet2]
union all
select * from [EXCEL 8.0;DATABASE=C:\info.XLS].[sheet3]
union all
select * from [EXCEL 8.0;DATABASE=C:\info.XLS].[sheet4]