Adding pictures as cell comments

Jason17

New Member
Joined
Apr 29, 2015
Messages
3
hi, i'm new to excel - i know, from browsing, that similar questions have been asked but i'd be really grateful if someone could help ;)

i'm trying to find a quick way to be able to insert a picture (jpg) as a comment in a cell - i've got lots of different pictures to insert as comments to lot of different cells.

While browsing, i found this macro:

Code:
Sub Img_in_Commentbox()
With Application.FileDialog(msoFileDialogFilePicker)
         .AllowMultiSelect = False          'Only one file
         .InitialFileName = CurDir         'directory to open the window
         .Filters.Clear                    'Cancel the filter
         .Filters.Add Description:="Images", Extensions:="*.jpg", Position:=1
         .Title = "Choose image"

         If .Show = -1 Then TheFile = .SelectedItems(1) Else TheFile = 0
    End With
'No file selected
If TheFile = 0 Then
MsgBox ("No image selected")
Exit Sub
End If
Range("A1").AddComment
    Range("A1").Comment.Visible = True
[A1].Comment.Shape.Fill.UserPicture TheFile
End Sub

it works (allows me to chose a picture to insert as a comment) but the problem i have is that whichever cell i select, it always inserts the picture as a comment to cell A1. I want to be able to insert the comment in whichever cell in the worksheet i choose - don't know how to change the macro to do this :(

Thanks in advance for any help ;)
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Welcome to the forum - to use the current active cell, try:

Rich (BB code):
Sub Img_in_Commentbox()
With Application.FileDialog(msoFileDialogFilePicker)
         .AllowMultiSelect = False          'Only one file
         .InitialFileName = CurDir         'directory to open the window
         .Filters.Clear                    'Cancel the filter
         .Filters.Add Description:="Images", Extensions:="*.jpg", Position:=1
         .Title = "Choose image"


         If .Show = -1 Then TheFile = .SelectedItems(1) Else TheFile = 0
    End With
'No file selected
If TheFile = 0 Then
MsgBox ("No image selected")
Exit Sub
End If
ActiveCell.AddComment
ActiveCell.Comment.Visible = True
ActiveCell.Comment.Shape.Fill.UserPicture TheFile
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,823
Messages
6,127,071
Members
449,358
Latest member
Snowinx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top