帮帮忙吧,excel导入access遇到问题

cainiao1212 2007-11-28 10:07:36
Private Sub ExportExcelSheetToAccess1(sSheetName As String, sExcelPath As String, sAccessTable As String, sAccessDBPath As String)
Dim SQL As String
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
Dim Constr As String
Constr = "PROVIDER = Microsoft.Jet.OLEDB.4.0; " & "Data Source= " & sAccessDBPath
conn.Open Constr
SQL = "select * into " & sAccessTable & " from [excel 8.0;database= " & sExcelPath & "].[ " & sSheetName & "$] "
conn.Execute SQL
conn.Close
Set conn = Nothing
End Sub
这是网上的一段代码
我修改后运行如下运行,提示“类型不匹配”
Private Sub Command1_Click()
Call ExportExcelSheetToAccess1([sheet1$], " D:\ssq.xls", "CompareBase", "D:\MHT_Data.mdb")
End Sub
如果将参数[sheet1$]改为"sheet1"又提示无效括号名称,请哪位大哥指点一下,谢谢了
...全文
43 点赞 收藏 回复
写回复
回复
切换为时间正序
请发表友善的回复…
发表回复

还没有回复,快来抢沙发~

发动态
发帖子
VB基础类
创建于2007-09-28

7451

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告