• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Hover over cells shows related picture stored in subfolder

inet

New Member
I refer to a great post (Interactive Dashboard in Excel using Hyperlinks) I saw from Chandoo and thought it can be relevant here - URL: http://chandoo.org/wp/2011/07/20/interactive-dashboard-using-hyperlinks/

I have posted this same thread in Ozgrid but I do suspect what I was asking was expected too much.
My intent is this, though: If you can please just help me get started and give advice. I am very willing to try it myself and would be happy (and proud :D) to post my progress and final solution back here again. I am relatively very new to event handling and this will be my first time embarking on this path. Neither do I have an example page as I am really stuck in planning and starting.

This was my question:

"I want to display jpeg images of 100's of garments listed in various sheets. With Winding font i have created a triangle/down arrow in each cell of say column G (like Chandoo has done in his post I mentioned above) where Column H has a description of the garment and each cell in column C has a unique garment identifier number, say "W16 ISO 018". The images will be stored in a subfolder e.g. c:\WorkbookFolder\Images with each name the same as the unique garment identifier number. The idea is to hover over the down arrow of a cell in column G which will pop up a picture of the garment and have it shown as a size of say 5cm by 10 cm. Moving the mouse off the link will let the picture disappear again.
I don't know how to go about this. Can you please assist? Garments will be added as it is created."

Just creating an ordinary hyperlink will not work, because this does not display the image in the Excel window but in an image viewer. Also I do not want to manually create a hyperlink to each row as new data will be added by the user. Alternative suggestions is also very welcome...if I can just get to do something that will work well please.

Thank you in advance for any advice or suggestions...
 
The file is attached
 

Attachments

  • MouseHoverOverImage.xlsm
    24.5 KB · Views: 52
  • W17 IS018.jpg
    W17 IS018.jpg
    10.3 KB · Views: 64
  • W16 IS021.png
    W16 IS021.png
    60 KB · Views: 39
1) Ensure Images are in "C:\WorkbookFolder\Images" folder or change path as required in the code
2) Ensure there are no duplicate images with different formats e.g. 12345.jpg, 12345.gif, 12345.png etc.

You will need to edit the image format info in the code if any other format apart from jpg/gif/png is used

Sample file attached
 

Attachments

  • Book1.xlsm
    17.5 KB · Views: 70
Last edited:
You could embed the image in a comment. It will then behave exactly as you want with no code involved.
Yeah I know lol. But seems that the user is making a product catalogue. So at some point it would no longer be a viable option to manually update as image in cell comments. Hence VBA as requested by user. But yeah its pretty easy to add in comments through the colours & lines bit
 
You could also use a UDF:

Code:
Function ImageViewer(sPicName As String) As String

    Dim cmt                   As Comment

    sPicFile = Dir(sPicName)
    If sPicFile <> vbNullString Then
        Set cmt = Application.ThisCell.Comment
        If cmt Is Nothing Then Set cmt = Application.ThisCell.AddComment()
        cmt.Text " "
        cmt.Shape.Fill.UserPicture sPicName
        ImageViewer = ChrW(&H25BA)
    Else
        ImageViewer = "No picture"
    End If
End Function

Then in the image cell enter:
=ImageViewer("C:\picture folder\"&A4&".png")
for example. The comment will be added with the picture in it.
 
1) Ensure Images are in "C:\WorkbookFolder\Images" folder or change path as required in the code
2) Ensure there are no duplicate images with different formats e.g. 12345.jpg, 12345.gif, 12345.png etc.

You will need to edit the image format info in the code if any other format apart from jpg/gif/png is used

Sample file attached


Wow wow wow! Thank you Chirayu. It works like a dream! Thank you so much! I got help by using a "click on hyperlink" which I will also share below as well. It just gives so much satisfaction getting things running so beautifully. I thank yo very much. Thank you also to all the other comments from Debaser and Khalid NGO. And Chandoo for giving us this space to get help
 
Wow wow wow! Thank you Chirayu. It works like a dream! Thank you so much! I got help by using a "click on hyperlink" which I will also share below as well. It just gives so much satisfaction getting things running so beautifully. I thank yo very much. Thank you also to all the other comments from Debaser and Khalid NGO. And Chandoo for giving us this space to get help
Chirayu. There is one thing that you in your code that I would like to clarify please. Hovering over the link does let the image pop up. But, when I move the mouse off the link, the image does not disappear again. Any advice on this please?
 
Attached is my example of inserting an image (helped received from my friend). In this case one has to click on the link. To remove the image again, the user must click on the image. In this case code is also placed in the active sheet to follow the hyperlink and the image is stored in the same folder. Code can be written to create hyperlinks for all the cells that needs this.
 

Attachments

  • imageInsert.xlsm
    15.2 KB · Views: 35
@inet

yeah unfortunately the code only really works on hover over hyperlink. Only way to make image disappear is you have a button to make it disappear, or a hyperlink specifically designed to make it disappear. There are more varied options too
 
Back
Top