Results 1 to 20 of 20

Thread: EXCEL VBA to show images as comments

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #13
    I was under the impression that you wanted something like this.
    If so, change references as and where required.
    The Cells in Column A need the filename without path and file extension.

    Sub Maybe_Try_So()
    Dim PicturePath As String
    Dim CommentBox As Comment
    Dim i As Long
    Dim fn
    
    
        For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row    '<---- Change the 1 to the first cell in Column A with a file name without extension
        fn = Dir("C:\Folder Name 1\Folder Name 2\Folder Name 3\" & Range("A" & i).Value & ".*")    '<---- Change to actual Folder(s)
            If Len(Dir("C:\Folder Name 1\Folder Name 2\Folder Name 3\" & Range("A" & i).Value & ".*", vbDirectory)) <> 0 Then    '<---- Change to actual Folder(s)
                PicturePath = fn
                Application.Range("A" & i).ClearComments
                    Set CommentBox = Application.Range("A" & i).AddComment
                    CommentBox.Text Text:=""
                    CommentBox.Shape.Fill.UserPicture (PicturePath)
                    CommentBox.Shape.Height = 20    '<---- Set size or use the AutoSize
                    CommentBox.Shape.Width = 20    '<---- Set size or use the AutoSize
                    'CommentBox.Shape.TextFrame.AutoSize = True
                    CommentBox.Visible = False
                Else
            End If
        Next i
    End Sub
    Last edited by jolivanes; 02-11-2021 at 11:12 PM. Reason: extra info

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •