|
本帖最后由 阳城 于 2012-3-18 16:56 编辑
我调试的Excel 导入问题 程序出错!!谢谢指点
Private Sub ExportExcelSheetToAccess(sSheetName As String, _
sExcelPath As String, sAccessTable As String, sAccessDBPath As String)
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase(sExcelPath, True, False, "Excel 5.0")
Call db.Execute("Select * into [;database=" & sAccessDBPath & "]." & _
sAccessTable & " FROM [" & sSheetName & "$]")
MsgBox "Table exported successfully.", vbInformation, "Yams"
End Sub
Private Sub Command0_Click()
Set fd = FileDialog(msoFileDialogFilePicker)
With fd
.ButtonName = "打开"
.Title = "请浏览文件"
.Filters.Clear
.Filters.Add "*.xlsx", "*.xls"
.InitialView = msoFileDialogViewList
.AllowMultiSelect = False
If .Show = -1 Then
Me.路径 = CStr(.SelectedItems(1))
End If
End With
ExportExcelSheetToAccess "Sheet1", "& me.路径 & ", "TestTable", _
"C:\Documents and Settings\Administrator\桌面\WAE\WAE.mdb"
end Sub
|
|