VB6.0将excel导入access中,提示错误“要求对象”
Dim str As StringDim 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 编辑 ]