Change pictures in Excel?

Discussion in 'Microsoft Excel Worksheet Functions' started by petterss, Aug 2, 2006.

  1. petterss

    petterss Guest

    petterss, Aug 2, 2006
    #1
    1. Advertisements

  2. petterss

    Ken Johnson Guest

    Ken Johnson, Aug 2, 2006
    #2
    1. Advertisements

  3. petterss

    petterss Guest

    Ken Johnson Wrote:
    > Hi peterss,
    >
    > Check out John McGimpsey's site...
    >
    > http://www.mcgimpsey.com/excel/lookuppics.html
    >
    > Ken Johnson



    Hi !
    I want to show a picture depending of a choice in a specific cell.
    have asked before and I get a link to some exempel, the problem is tha
    a get an error message and I dont now what to do (I´m a amateur!).

    The link was: http://www.mcgimpsey.com/excel/lookuppics.html

    I copy the code to my file, but I get an "error 13 - miss match" al
    the time.
    Code:
    Private Sub Worksheet_Calculate()
    Dim oPic As Picture
    Me.Pictures.Visible = True
    With Range("B41")
    For Each oPic In Me.Pictures
    If oPic.Name = .Text Then
    oPic.Visible = True
    oPic.Top = .Top
    oPic.Left = .Left
    Exit For
    End If
    Next oPic
    End With
    End Sub

    "oPic.Name" never get the same like ".Text", my pictures have name
    like 212,213... but "oPic.Name" is like 103,104...
    So when it comes to "Next oPic" it stops!

    What should I do? Where is the pictures defind? Whats "Me.Pictures"?

    Thank

    --
    petters
    -----------------------------------------------------------------------
    petterss's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3635
    View this thread: http://www.excelforum.com/showthread.php?threadid=56736
     
    petterss, Aug 11, 2006
    #3
  4. petterss

    rowem

    Joined:
    Nov 8, 2007
    Messages:
    1
    Likes Received:
    0
    I came accross a similar problem with the script, it seems to happen if you have "things" on your spreadsheet which are recorded in Me.Pictures but are not acutally pictures; buttons, listboxes etc...

    You need to specifically list your pictures, make them invisible, then I used an IF statement to look at the cell containing the picture name and display the relevant pic. Like this:

    Private Sub Worksheet_Calculate()
    Dim x As Integer
    Dim Pics(9) As String 'Holds all the pic names

    'Picture 1 and 2 are a listbox and a button, so I want these visible
    Sheets(1).Shapes("Picture 1").Visible = True
    Sheets(1).Shapes("Picture 2").Visible = True

    'These are my pics that I want to hide and display
    Sheets(1).Shapes("Picture 3").Visible = False
    Sheets(1).Shapes("Picture 4").Visible = False
    Sheets(1).Shapes("Picture 5").Visible = False
    Sheets(1).Shapes("Picture 6").Visible = False
    Sheets(1).Shapes("Picture 7").Visible = False
    Sheets(1).Shapes("Picture 8").Visible = False
    Sheets(1).Shapes("Picture 9").Visible = False
    Sheets(1).Shapes("Picture 10").Visible = False
    Sheets(1).Shapes("Picture 11").Visible = False
    Sheets(1).Shapes("Picture 12").Visible = False

    'Fill the array with your pic names
    Pics(0) = "Picture 3"
    Pics(1) = "Picture 4"
    Pics(2) = "Picture 5"
    Pics(3) = "Picture 6"
    Pics(4) = "Picture 7"
    Pics(5) = "Picture 8"
    Pics(6) = "Picture 9"
    Pics(7) = "Picture 10"
    Pics(8) = "Picture 11"
    Pics(9) = "Picture 12"
    x = 0

    With Range("K1") 'K1 is where I want my pic displayed

    Do While x <= 9 'Read and match the contents with your pic
    If .Text = Pics(x) Then
    Sheets(1).Shapes(Pics(x)).Visible = True
    Sheets(1).Shapes(Pics(x)).Top = .Top
    Sheets(1).Shapes(Pics(x)).Left = .Left

    End If
    x = x + 1

    Loop
    End With

    End Sub

    Hope this helps,
    Matt
     
    rowem, Nov 8, 2007
    #4
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ira

    pictures in excel

    ira, Jul 10, 2003, in forum: Microsoft Excel Worksheet Functions
    Replies:
    4
    Views:
    122
  2. Diamond1708

    Paste Pictures in Excel

    Diamond1708, Jan 20, 2004, in forum: Microsoft Excel Worksheet Functions
    Replies:
    1
    Views:
    173
    Jonathan Rynd
    Jan 20, 2004
  3. BadBoySami

    import pictures into excel

    BadBoySami, Jan 30, 2004, in forum: Microsoft Excel Worksheet Functions
    Replies:
    1
    Views:
    233
    Gilles Desjardins
    Jan 31, 2004
  4. Gerry

    Pictures in excel

    Gerry, May 24, 2004, in forum: Microsoft Excel Worksheet Functions
    Replies:
    2
    Views:
    157
    Gerry
    May 25, 2004
  5. ang

    Pictures in Excel

    ang, Oct 7, 2004, in forum: Microsoft Excel Worksheet Functions
    Replies:
    1
    Views:
    132
    Frank Kabel
    Oct 7, 2004
Loading...

Share This Page