首页上一页 1 下一页尾页 3 条记录 1/1页
求助:vb将excel导入access中提示错误 424 “要求对象”
发表在VB答疑区
2015-01-04
是否精华
是
否
版块置顶:
是
否
VB6.0将excel导入access中,提示错误“要求对象”
Dim str As String
Dim conn As ADODB.Connection
Private Sub Command1_Click()
Me.CommonDialog1.ShowOpen
str = Me.CommonDialog1.FileName
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
Dim str As String
Dim conn As ADODB.Connection
Private Sub Command1_Click()
Me.CommonDialog1.ShowOpen
str = Me.CommonDialog1.FileName
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