Results 1 to 3 of 3

Thread: Import and Rename Picture in Excel 07

  1. #1

    Import and Rename Picture in Excel 07

    Register for a FREE account, and/
    or Log in to avoid these ads!

    I'm working on an application that will add a picture based on a series of previous selections. The selection culminate in the name of the image I need in cell c67 of sheet "Info". It then pastes it at cell a15 of sheet "Setup" Here is the code for pulling in the picture.

    Filename = Filepath & info.Range("c67") & ".jpg"
    With setup.Range("a15")
        Set pic = setup.Shapes.AddPicture(Filename, msoFalse, msoTrue, .Left, .Top, 300, 240)
    End With
    What I'm having trouble with is a way to automatically change the name of the newly embedded picture so as to be able to manipulate it. My desire is that each time a dropdown selection is made from the dropdown menu in question, it will delete the previous photo and make the new one appear. The last selection is to be kept for later usage in the application. My first thought is just to code a macro to search every shape name until it finds the only one with "Picture" in the name. I'm not quite sure how to do that though. All thoughts and suggestions are much appreciated.


  2. #2


    Ok, so I've kept at it a little, but am still stuck.

    Dim Rshape as shape
    for each rshape in setup.shapes
        if = "picture *" then = info.range("c67")
        end if
    next rshape
    This coding enable me to find the shape in question as it will be the only one with a name that starts with Picture. The code in red however is not functioning. When I check the image, it is still name Picture X.


  3. #3
    Ok, so got it figured out. Need the code to read:

    Dim Rshape as shape
    for each rshape in setup.shapes
        if Like "Picture *" then = info.range("c67")
        end if
    next rshape
    When I switched the "=" to "Like" per a suggestion from Tom Ogilvy at it didn't change anything at all. However, when I capitalized the "p" in "Picture" voila, everything was good to go. Not sure exactly why but apparently it had to be case sensitive.

Posting Permissions

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