实现选择路径后导入
我要实现选择路径后导入,看下以下代码,请各位高手指点
Option Explicit
Private Sub Dir1_Change()
File1.Pattern = ("*.*")
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
Text1.Text = "" & Dir1.List(-1) & "" & File1.FileName
Dim ljing As String
ljing = Text1.Text
End Sub
Private Sub Command1_Click()
'access导出到excel
Dim db As New ADODB.Connection
Dim sPath As String
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= ljing Persist Security Info=False" sPath = App.Path + "\backup.xls"
If Dir(sPath) <> "" Then
Kill sPath
Else
Call db.Execute("select * into Sheet1 In '" & sPath & "' 'excel 8.0;' from 表1")
MsgBox "导出成功", vbOKOnly, "提示"
End If
db.Close
Set db = Nothing
End Sub
Private Sub Command2_Click()
'从excel导出到 access
Dim db As New ADODB.Connection
Dim sPath As String
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=ljing;Persist Security Info=False" sPath = App.Path + "\backup.xls"
Call db.Execute("select * into Table4 From [Sheet1$] In '" & sPath & "' 'excel 8.0;'")
db.Close
Set db = Nothing
End Sub
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= ljing Persist Security Info=False"错误应该怎么改
[解决办法]
拷贝了代码,起码要稍微理解一下;
很明显的,那是两行代码(红色一行,黑色一行)