标题:VB6.0将excel导入access中,提示错误“要求对象”
只看楼主
wangzhongda
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2014-11-10
结帖率:100%
 问题点数:0 回复次数:0 
VB6.0将excel导入access中,提示错误“要求对象”
Dim str As String
Dim conn As ADODB.Connection
Private Sub Command1_Click()

str =
Text1.Text = str
End Sub
Private Sub Command2_Click()
Dim conn As New ADODB.Connection
Right1 = Right(str, 4)
If Right1 <> ".xls" Then
MsgBox "不能识别该文件,请输入正确的表导入"
Else
Set conn = New ADODB.Connection
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\file.mdb;Persist Security Info=False"
conn.Execute "select * into tmptable from [excel 8.0;database=" & TDS.xls & "].[sheet] "
conn.Execute "insert into 最初导入表(服务站代码,服务站名称,申请单号,工时费,材料费,附加费,外出燃油费,外出住宿费,外出补助费,外出工时费,主损件代码,主损件名称,索赔金额,审核日期) select 服务站代码,服务站名称,申请单号,工时费,材料费,附加费,外出燃油费,外出住宿费,外出补助费,外出工时费,主损件代码,主损件名称,索赔金额,供应商审核日期 from tmptable"
conn.Execute "drop tabel tmptable"
Set conn = Nothing
MsgBox "成功导入"
Me.Adodc1.Refresh
Me.DataGrid1.Refresh
End If
End Sub

[ 本帖最后由 wangzhongda 于 2015-1-4 15:04 编辑 ]
搜索更多相关主题的帖子: excel access False 
2015-01-04 15:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-440676-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012527 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved