想找个老师帮忙解释一下这段代码的意思和优缺点!
PrivateSubExportExcelSheetToAccess(sSheetNameAsString,_sExcelPathAsString,sAccessTabl...
Private Sub ExportExcelSheetToAccess(sSheetName As String, _
sExcelPath As String, sAccessTable As String, sAccessDBPath As String)
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase(sExcelPath, True, False, "Excel 5.0")
Call db.Execute("Select * into [;database=" & sAccessDBPath & "]." & _
sAccessTable & " FROM [" & sSheetName & "$]")
MsgBox "准备就绪", vbInformation, "Yams"
End Sub
Private Sub Command1_Click()
ExportExcelSheetToAccess "Sheet1", "C:\book1.xls", "TestTable", "C:\Test.mdb"
End Sub
在网上找到的代码!但是我见短短的几行代码就已经能完成excel导入Access 了!有老师可以逐行解释下吗?还有他有什么优缺点?
还有就是当数据库里面已经有TestTable这个表之后就会出错!有什么方法可以解决呢?谢谢老师啦!
我想是如果检测到TestTable表存在就删掉再重新导入!应该怎么写呢? 展开
sExcelPath As String, sAccessTable As String, sAccessDBPath As String)
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase(sExcelPath, True, False, "Excel 5.0")
Call db.Execute("Select * into [;database=" & sAccessDBPath & "]." & _
sAccessTable & " FROM [" & sSheetName & "$]")
MsgBox "准备就绪", vbInformation, "Yams"
End Sub
Private Sub Command1_Click()
ExportExcelSheetToAccess "Sheet1", "C:\book1.xls", "TestTable", "C:\Test.mdb"
End Sub
在网上找到的代码!但是我见短短的几行代码就已经能完成excel导入Access 了!有老师可以逐行解释下吗?还有他有什么优缺点?
还有就是当数据库里面已经有TestTable这个表之后就会出错!有什么方法可以解决呢?谢谢老师啦!
我想是如果检测到TestTable表存在就删掉再重新导入!应该怎么写呢? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询