+ Reply to Thread
Results 1 to 7 of 7

Code to insert Image into Excel?

  1. #1
    Registered User
    Join Date
    07-13-2011
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2007
    Posts
    12

    Exclamation Code to insert Image into Excel?

    I want Excel to call up an image to match a series of cells I have created. The logic is this: a user selects from 6 Yes/No fields, and depending on their combination, I want a specific image that is stored on the hard drive to appear in excel. There are different images I need to display with the various Yes/No combinations. For example a chain of Yes/Yes/No should bring up a different image than Yes/No/Yes. I think this would require a macro but I dont know how to approach it. I would prefer for the image to be automatically generated as soon as the user inputs his/her Yes/No fileds, but macro run button presses are fine as well. Anyone have any ideas?
    Last edited by slamups21; 07-18-2011 at 10:18 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Code to insert Image into Excel?

    Hello slamups21,

    Welcome to the Forum!

    Where will the picture be placed on the worksheet? It would best if you post the workbook to get a solution faster.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-13-2011
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Code to insert Image into Excel?

    Thanks! I have attached a rough early version of the workbook with notes to make things a little clearer. I would like the image to be placed close to the user input cells, I have specified the region in the workbook attached.
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Code to insert Image into Excel?

    Hello slamups21,

    Inserting the picture is easy. Calling the macro to do so is the tricky part. Based on the logic of selections you have, it would be best to add a button to do 2 things: Validate the user's selections and retrieve the proper picture for that selection. Would this option work for your needs?

  5. #5
    Registered User
    Join Date
    07-13-2011
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Code to insert Image into Excel?

    This is a good solution to the problem, but Is there any way to automate it in such a way that no button needs to be pressed? I.e. that the picture is updated and changed just like a cell with a formula in it? If this is not possible, then the solution you proposed is definitely the next best thing and I would love to see how to make a button that yields such a result.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Code to insert Image into Excel?

    Hello slamups21,

    The problem is knowing when the user has finished making his/her selections. Do this without a button requires using the Worksheet_Change event. This would run the macro each time changed on the cells in the "Yes" column and display a picture if the criteria are met. This could prove annoying.

    The other problem is the choices are not all single but can also be in combinations. You would then have to prioritize the combinations. For example, if the users chooses 2 and then chooses 3, which combination on is it: 2+3 or 3+2?

  7. #7
    Registered User
    Join Date
    07-13-2011
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Code to insert Image into Excel?

    You raise an interesting issue. The list of combinations will not be including duplicates, so in your example, 2+3 and 3+2 would bring up the same image. I would honestly much prefer an automatically generated image, since there will be some default Yes/No values and I expect users will change one to two of them depending on their preference. The annoyance factor is definitely something to keep in mind though, and I think I would have to see it to really assess how much of a nuisance it would be. I think in the end it would be best if I could get some help on how to do it both ways, i.e., with and without the button, and decide which method is better.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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