I'm trying to create a database in excel that includes images. The best way to do this seems to be to use a comment with the picture as the background of the comment. Unfortunately, I have around 100 observations, and this will be somewhat time consuming.
I'm very new to VBA. I know Python, and Matlab, but I'm just starting VBA.
Essentially, I need to:
- Create a comment for a given cell
- Remove any text from the commment
- Remove any line border from the comment
- resize the dimensions of the comment to width = 5 inches and height = 6.5 inches.
- fill the background with a specified image.
Now, all the images I need to use are in a specific folder. And I've included the filename in a call adjacent to the cell I'm trying to add the comment to.
So, I'm not exactly sure how to accomplish the above in VBA. I've started by recording a macro that yields some code which I modified to do the exact same thing with multiple cells. The only thing is, I need it to use a different image for the background for each comment. How might I accomplish this? It seems like I would need to set up some sort of a loop to go over all of the cells. Then, for the step to change the background, I would need to use the value next cell over to specify the location of the picture I want to use.
Unfortunately, my VBA skills are not quite up to this challenge. Any help would be much appreciated.
Sub Macro3()
'
' Macro3 Macro
'
' Keyboard Shortcut: Option+Cmd+g
' Range("C25:C50").AddComment
' Range("C25:C50").Comment.Visible = False
' Range("C25:C50").Comment.Shape.Select True
' Range("C25:C50").Comment.Text Text:="" & Chr(13) & ""
' Selection.ShapeRange.Line.Weight = 0.75
' Selection.ShapeRange.Line.DashStyle = msoLineSolid
' Selection.ShapeRange.Line.Style = msoLineSingle
' Selection.ShapeRange.Line.Transparency = 0#
' Selection.ShapeRange.Line.Visible = msoFalse
' Selection.ShapeRange.Fill.Visible = msoTrue
' Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 255)
' Selection.ShapeRange.Fill.BackColor.RGB = RGB(251, 254, 130)
' Selection.ShapeRange.Fill.Transparency = 0#
' Selection.ShapeRange.Fill.UserPicture _
' "OWC Mercury Extreme Pro:Users:austinwismer:Desktop:Flange:IMG_2626.JPG"
' Selection.ShapeRange.LockAspectRatio = msoFalse
' Selection.ShapeRange.Height = 468#
' Selection.ShapeRange.Width = 360#
End Sub