Can EXCEL show the picture from the database ?

  • Thread starter Thread starter worldapart
  • Start date Start date
W

worldapart

i have written codes in excel to show data from database(MsSQL) all o
them can be done except pictures .does anyone know that excel can sho
the picture from the database ?:eek
 
You dont say how you are displaying the data. So the answer can only be
very general.

Where and how are you displaying the data?
How is the picture "stored" in the database?
What format is the stored data?

But principlaay you will need to place a container of some sort (eg a
shape or a VBA ImageControl) depending on what you are going to do with
it) and set the property of the control to the image file or to an
imageControl.

If the number of images is dynamic then you will benefit by creating
the containers (position and size) on the fly.

More clarity in your question may result in a more prescriptive
answer.

regards,
 
I've used this with Oracle.
oConn is a global variable (ado connection)

*********************************************************************

Sub ReadFile()
Dim stempfile As String
stempfile = "C:\local files\temp.gif"
Dim rs As ADODB.Recordset

Set rs = oConn.Execute("SELECT t.blobcolumn FROM tablename t WHERE t.id
= 2")

'Write it to disk
Dim oStream
Set oStream = CreateObject("adodb.stream")
With oStream
.Type = adTypeBinary
.Open
.Write (rs.Fields("dcmtblob2").Value)
.SaveToFile stempfile, adSaveCreateOverWrite
.Close
End With

shtData.Range("C6").Select
shtData.OLEObjects.Add Filename:=stempfile, Link:=False,
DisplayAsIcon:=False

rs.Close
Set rs = Nothing
Set oStream = Nothing

End Sub
****************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top