+ Reply to Thread
Results 1 to 3 of 3

Can EXCEL show the picture from the database ?

  1. #1
    Registered User
    Join Date
    02-10-2006
    Posts
    1

    Can EXCEL show the picture from the database ?

    i have written codes in excel to show data from database(MsSQL) all of them can be done except pictures .does anyone know that excel can show the picture from the database ?

  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187
    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,

  3. #3
    Tim Williams
    Guest

    Re: Can EXCEL show the picture from the database ?

    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
    ****************************************************
    --
    Tim Williams
    Palo Alto, CA


    "tony h" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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,
    >
    >
    > --
    > tony h
    > ------------------------------------------------------------------------
    > tony h's Profile:

    http://www.excelforum.com/member.php...o&userid=21074
    > View this thread: http://www.excelforum.com/showthread...hreadid=510960
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1