0

我正在尝试通过 VBA 代码导出一些作为附件嵌入的图片。.SaveToFile出于某种原因,我不断收到编译错误:在零件上找不到方法或数据成员。

   Private Sub btnExport_Click()
'  Instantiate the parent recordset.

Dim rsPicture As ADODB.Recordset
Set rsPicture = New ADODB.Recordset

rsPicture.ActiveConnection = CurrentProject.Connection

rsPicture.Open "Select * from Pictures"

rsPicture.MoveFirst

 '  Set rsPicture = db.OpenRecordset("Pictures")


   ' Instantiate the child recordset.
   Set rsPicture = rsPictureTable.Fields("Picture").Value

   '  Loop through the attachments.
   While Not rsPicture.EOF

      '  Save current attachment
      rsPicture.Fields("FileData").SaveToFile _
                  "C:\Pics"
      rsPicture.MoveNext
   Wend

End Sub
4

1 回答 1

0

附件在一个Recordset2对象(和一个Field2)中:

Set rsPicture = New ADODB.Recordset2

正如错误消息所说,实际上,Field对象没有SaveToFile方法,而Field2对象有。

这里有一个比帮助系统中的示例更完整的示例。

于 2013-07-30T14:30:22.957 回答