我想編碼一個簡單的任務:從Access(2013)數據庫檢索附件並將其保存到磁盤。此刻,我希望代碼從記錄集中獲取第一條記錄並將附件保存到C:\ maptest.pdf保存附件到硬盤
它顯示錯誤3265:在此集合中找不到項目(但數據庫中的每個記錄都有一個附件)。
有沒有人有一個想法我做錯了什麼?
Private Sub CommandButton4_Click()
Dim appAcc As New Access.Application
Dim rst As DAO.Recordset2
Dim rsA As DAO.Recordset2
Dim fld As DAO.Field2
Dim dbpath As String
dbpath = ThisWorkbook.Path & "\SiteDetails.accdb"
With appAcc
.OpenCurrentDatabase dbpath
Set rst = .CurrentDb.OpenRecordset("SiteMaps")
Set rsA = rst.Fields("Map").Value
End With
rsA.Fields("Map").SaveToFile _"C:\maptest.pdf"
AppAcc.Quit
Set appAcc = Nothing
End Sub
請仔細閱讀本文:[應該在標題中包含「標籤」?](http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles) –
行是這個錯誤? – RubberDuck
它顯示錯誤:rsA.Fields(「Map」)。SaveToFile _「C:\ maptest.pdf」但當我更改「地圖」到「FileData」它工作正常。似乎我不必引用名爲「Map」但是「FileData」的列(即使FileData不存在作爲列) – user3520938