I would like to insert a picture (.jpg,.png) into an Excel sheet from an attachment' field from Access.
My current code is something like this:
Sub InsertPicFromAccessDB()
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
con.ConnectionString = ConStrAccess
con.Open
With rs
.ActiveConnection = con
.Source = "SELECT ProdutoFoto FROM tblProduto WHERE ProdutoFoto=2163150;"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open
End With
shStockNovo.Range("A57").Value = rs.Fields(0).Value
rs.Close
con.Close
End Sub
It doesn't upload the image from the DB.
I already searched for other alternatives and one sugestion was using the ADODB.Sream. But it gave me an error on the "ADODB.Stream.Write" (with my research, no one could fix this problem). It was the "Run Time Error ‘3001’ Arguments are the wrong type, are out of acceptable range, or are in conflict with one another."