Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2002
    Bay Area

    Question Unanswered: Can Embedded Image be Displayed on Form?

    Is it possible to retrieve an imbedded image from a collection of thumbnail images stored in a worksheet, and display an image in an Excel 2003 form?
    I'm curious to know if there is an alternative to working with image files.

    My goal is to use a list of bird species and display an image after selection.

  2. #2
    Join Date
    Oct 2003
    I've never tried with an embedded image but if the below helps in anyway, you might be able to tweak it for an embedded result.

    When Command1 is pressed, it deletes the picture called 'ChangingImage' and then inserts a new one based on the value of ImgPath. My own path called another function so I've removed all that from this. You just need to identify where the ImgPath would be assigned, i.e. from a cell value, or a selected item in a list box...

    Sub Command1_Click()
    Dim Sh As Shape
    Dim ImgPath As String
    ImgPath = ""  
    For Each Sh In ActiveSheet.Shapes
        If Sh.Name = "ChangingImage" Then
        End If
    Next Sh
        Selection.ShapeRange.Height = 275
        Selection.Name = "ChangingImage"
    End Sub

  3. #3
    Join Date
    Jan 2002
    Bay Area
    Christyxo, I used your example to view images in a worksheet, but was unable to adapt the code to populate an image control from an
    embedded thumbnail image in the workbook. Thank you for your efforts with that.
    I did have success using someone else's code, and it can be seen in Module1 in the attached Excel 2003 file. The source is documented
    at the top of the code. The form and its code are my own creation.
    The trick is that this function assigns clipboard contents to the image control. I found that after I closed the form, the clipboard still had
    the last image, even after using this:
    Application.CutCopyMode = False
    To clean up the clipboard, in the form termination event, a cell is copied followed by the above code. Here is the form's code.
    Private Sub UserForm_Activate()
    Dim shp As Shape
        With Sheets("Sheet3")
            For Each shp In .Shapes
                Me.cboBirdImageList.AddItem shp.Name
        End With
    End Sub
    Private Sub cboBirdImageList_Change()
    Dim birdName As String
    Dim birdImage As Shape
        birdName = Me.cboBirdImageList
        Application.ScreenUpdating = False
        'PastePicture code in Module1 will assign image copied
        'to clipboard, to image control on the form
        Me.Image1.Picture = PastePicture
        Application.ScreenUpdating = True
        Me.cmdDummy.SetFocus    'remove focus from the combo box
    End Sub
    Private Sub UserForm_Terminate()
      ActiveSheet.Cells(1, 1).Copy
      Application.CutCopyMode = False
    End Sub
    Attached Files Attached Files

Posting Permissions

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