[VBA ] 關於EXCEL 連結 ACCESS (automation錯誤)

看板Visual_Basic作者 (黑狗)時間11年前 (2013/12/01 19:17), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
小弟想使用excel的vba去連結access抓資料 版本是2010 但發生了以下錯誤 執行階段錯誤 -2147467259 (80004005) Automation 錯誤 無法指出的錯誤 ---------------------------- 以下是我的程式碼 Sub test3() Dim rst As New ADODB.Recordset Dim mydeta, SQLstr As String mydeta = ThisWorkbook.Path & "\System.accdb" If Dir(mydeta) = "" Then MsgBox "資料庫檔案不存在!請聯繫程序維護人!", vbExclamation, "無法連接資料 庫" Exit Sub End If rst.ActiveConnection = _ "Provider = Microsoft.ACE.OLEDB.12.0;" & _ "Data Source = C:\Users\ATC\Desktop\System.accdb;" SQLstr = " SELECT * FROM 產品 " rst.Open SQLstr 'MsgBox rst.GetString Sheet3.Range("A1").CopyFromRecordset rst rst.Close Set rst = Nothing End Sub ------------------------- 主要是紅色那段發生錯誤 但網路查似乎找不太到 懇請各位板上大大指教錯誤 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.224.218.48 ※ 編輯: hatedog5566 來自: 61.224.218.48 (12/01 19:19)
文章代碼(AID): #1IcnhPDB (Visual_Basic)
文章代碼(AID): #1IcnhPDB (Visual_Basic)