Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display a picture in Excel

Status
Not open for further replies.

GFAlexander

IS-IT--Management
Nov 12, 2001
68
GB
I have a spreadshhet that has product codes in column A. I would like that if a user hovers over or clicks a cell in column A, a picture of the product is displayed.

The picture files will all be in the same directory and will be the same as the product code in column A. In an ideal world, the picture would open in a seperate (small) window with an option to close it.

Is there a formula, some code or formatting that I can use yo achieve this?

Thanx

Gary
 
Use a picture in a comment. Single-click a cell, Insert > Comment > Right-click the border of the comment > Format Comment > Colors and Lines > Fill Color > Fill Effects > Picture > Select Picture > After selecting picture, o.k. everything out. While comment border is still selected, drag the corner out to adjust the size. Click anywhere else in the sheet. Now hover over cell to show picture.

Flores
 
newbiewonkinobie: Very nice! The only thing is that depending on how many pictures are included, the worksheet may become quite large. Also, if the pictures are ever updated, the comment(s) would have to be updated manually.

Gary: If you have a great many pictures to show in that way (and you want to keep them separate from the worksheet), there are a couple of other things you could do:

1. The easiest way is simply to insert a hyperlink directly to the file.

2. The other (harder) way is to use VBA to create a form with an image and a command button (to close the form). You can trap the SelectionChange event and use that macro to load the image with the designated picture file and then show the form. For example:
[blue]
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
  If UCase(Right(Target.Value, 4)) = ".JPG" Then
    UserForm1!Image1.Picture = _
      LoadPicture("C:\My Documents\My Pictures\" & Target.Value)
    UserForm1.Show
  End If
End Sub
[/color]


Of course, if what you are doing is creating some sort of catalog you may actually prefer to put the pictures in comments so that you only have to distribute the one worksheet file and not have to include all of the pictures as separate files. That's actually a pretty neat idea.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top