|
把excel追加导入到access数据库
'1、sSheetName:要导出资料的资料表名称 (Sheet name),例如 Sheet1
'2、sExcelPath:要导出资料的 Excel 文件路径名称 (Workbook path),例如 C:\book1.xls
'3、sAccessTable:要导入的 Access Table 名称,例如 TestTable
'4、sAccessDBPath:要导入的 Access 文件路径名称,例如 C:\Test.mdb
Private Sub ExportExcelSheetToAccess(sSheetName As String, sExcelPath As String, sAccessTable As String, sAccessDBPath As String)
Dim db As Database
Dim rs As DAO.Recordset
Set db = OpenDatabase(sExcelPath, True, False, "Excel 8.0")
'db.Execute ("Select * into [;database= " & sAccessDBPath & "]." & sAccessTable & " FROM [ " & sSheetName & "$]")
db.Execute ("insert into [;database=" & sAccessDBPath & "]." & sAccessTable & " select * from [" & sSheetName & "$]")
db.Close
Set db = Nothing
End Sub
http://club.excelhome.net/thread-745574-1-1.html |
|