+ Reply to Thread
Results 1 to 4 of 4

MouseOver cell that makes apear and disappear an image

Hybrid View

  1. #1
    Registered User
    Join Date
    06-19-2012
    Location
    Rio
    MS-Off Ver
    Excel 2010
    Posts
    3

    MouseOver cell that makes apear and disappear an image

    Hi mates.

    I need the same thing that has been posted on this thread, but updated to Excel 2010:
    http://excel.bigresource.com/Track/excel-a6YFd1sx/

    The original code was:
    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
    Wich stopped working on Excel 2003 because Application.FileSearch isnt used anymore.

    This link http://excel2007tips.blogspot.com/20...h-in-2007.html has been posted in the same topic as a solution, but i couldnt get it implemented.

    Please, can you help me ?

    Best regards

  2. #2
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474

    Re: MouseOver cell that makes apear and disappear an image

    Try...

    Option Explicit
    
    Sub AddPicToCellComment()
    
        Dim strPath As String
        Dim strFile As String
        
        strPath = ThisWorkbook.Path & "\"
        
        strFile = Dir(strPath & "*.jpg", vbNormal)
        
        If Len(strFile) <> 0 Then
            With Range("A1")
                .ClearComments
                .AddComment
                With .Comment.Shape
                    .Fill.UserPicture strPath & strFile
                    .Width = 600
                    .Height = 400
                End With
            End With
        Else
            MsgBox "No JPG file found...", vbExclamation
        End If
        
    End Sub

  3. #3
    Registered User
    Join Date
    06-19-2012
    Location
    Rio
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: MouseOver cell that makes apear and disappear an image

    Hi Domenic, thank you very much for your feedback.

    The code worked perfecly but only on CEL A1, can it search for images at the whole Column G (Sorry for the missing info).

    In time, is there a way to always show the comment at the center of the screen ? Some of the images shown are big and if they appear right next to the cell the user will need to scroll down.

    I found this code wich, if i click on the comment cel, it moves the Comment Shape a little left/right, but i need it on the absolut center.

    Best regards

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim targetCom As Comment
    If Target.Cells.Count = 1 Then
    On Error Resume Next
    Set targetCom = Target.Comment
    On Error GoTo 0
    If Not targetCom Is Nothing Then
    If ActiveCell.Column > 31 Then
    With targetCom
    .Shape.Top = .Parent.Offset(2, 0).Top
    .Shape.Left = .Parent.Offset(2, -10).Left
    End With
    Else
    With targetCom
    .Shape.Top = .Parent.Offset(2, 0).Top
    End With
    End If
    End If
    End If

  4. #4
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474

    Re: MouseOver cell that makes apear and disappear an image

    The code worked perfecly but only on CEL A1, can it search for images at the whole Column G (Sorry for the missing info).
    Can you please clarify?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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