+ Reply to Thread
Results 1 to 7 of 7

Thread: MouseOver cell that makes apear and disappear an image

  1. #1
    Registered User
    Join Date
    12-15-2009
    Location
    Lx, Pt
    MS-Off Ver
    Excel 2003
    Posts
    3

    Talking MouseOver cell that makes apear and disappear an image

    Hello,
    Please Help

    I would like to do a routine in VBA on excel 2007 that makes the following:
    1- When the mouse is over a cell it pops-up a window that shows a picture;
    2- When the pointer is removed from the cell the window that contains the picture closes;
    It is very important that the picture that is shown be adressed by a relative path from the folder in which is the excel file.
    The pictures can change; this is the reason that the picture should be addressed by a path.

    Thanks a lot
    Last edited by first_mo_za; 12-17-2009 at 08:24 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Cochrane,Alberta
    MS-Off Ver
    XL 2003,2007,2010
    Posts
    6,843

    Re: MouseOver cell that makes apear and disappear an image

    Is the path address in the cell?

  3. #3
    Registered User
    Join Date
    12-15-2009
    Location
    Lx, Pt
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: MouseOver cell that makes apear and disappear an image

    Dave,

    The "address" is the same folder in which the excel is.
    Thkx

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Cochrane,Alberta
    MS-Off Ver
    XL 2003,2007,2010
    Posts
    6,843

    Re: MouseOver cell that makes apear and disappear an image

    This code will find the .jpg in the active workbook folder and place the address into cell G1.
    It will then add a comment into A1 and use the address in G1 as the source.
    Sub AddPicToCellComment()
        Dim r As Range, i As Range
    
        Set r = Range("G1")
        Set i = Range("A1")
    
    
        With Application.FileSearch
            .LookIn = ThisWorkbook.Path
            .Filename = "*.jpg"
            If .Execute > 0 Then    'there is a .jpg
                r = .FoundFiles(1)
            End If
        End With
    
        With i
            .ClearComments
            .addComment
        End With
    
        With i.Comment.Shape
            .Fill.UserPicture r
            .Width = 600
            .Height = 400
    
        End With
    
    
    End Sub

  5. #5
    Forum Guru
    Join Date
    10-28-2008
    Location
    Not here anymore
    MS-Off Ver
    irrelevant
    Posts
    10,151

    Re: MouseOver cell that makes apear and disappear an image

    Just quoting here, but a similar topic came up yesterday in another thread

    Quote Originally Posted by Andy Pope View Post
    There are no mouse movement events for a workbook.

    Activex controls on the worksheet have mouse events as do controls on a userform.
    Edit: Scratch that then, comments are obviously the exeption. Nice!

  6. #6
    Registered User
    Join Date
    12-15-2009
    Location
    Lx, Pt
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: MouseOver cell that makes apear and disappear an image

    Dave,

    Sorry. It gives me an error "run-time error 445" at the linecode "With Application.FileSearch"

    Thkx

    EDIT: Thkx Dave. I've solved the issue. I realized that Application.Filesearch is no longer available in excel 2007. I got it to work with this from Roy's blog http://excel2007tips.blogspot.com/20...h-in-2007.html

    Thank you
    Last edited by first_mo_za; 12-16-2009 at 01:02 PM.

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Cochrane,Alberta
    MS-Off Ver
    XL 2003,2007,2010
    Posts
    6,843

    Re: MouseOver cell that makes apear and disappear an image

    I did not know that, I had just assumed that XL'07 could run XL'03 VBA, thanks for the link.

    Could you supply the code so people with XL'07 can use it.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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.2.0