Insert Picture in a cell and name the picture in the next cell

monkeyspank

Board Regular
Joined
Feb 12, 2014
Messages
72
I have found a macro that will capture multiple pictures and upload the pictures into the Excel cells, but I also want to show the name of the picture i uploaded in the cell. Is this even possible?

VBA Code:
Private Sub CommandButton1_Click()
Dim PicList() As Variant
Dim PicFormat As String
Dim Rng As Range
Dim sShape As Shape
On Error Resume Next
PicList = Application.GetOpenFilename(PicFormat, MultiSelect:=True)
xColIndex = Application.ActiveCell.Column
If IsArray(PicList) Then
    xRowIndex = Application.ActiveCell.Row
    For lLoop = LBound(PicList) To UBound(PicList)
        Set Rng = Cells(xRowIndex, xColIndex)
        Set sShape = ActiveSheet.Shapes.AddPicture(PicList(lLoop), msoFalse, msoCTrue, Rng.Left, Rng.Top, Rng.Width, Rng.Height)
        xRowIndex = xRowIndex + 1
    Next
      
End If
End Sub
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
1,969
I guess this modification should work:
VBA Code:
        Set sShape = ActiveSheet.Shapes.AddPicture(PicList(lLoop), msoFalse, msoCTrue, Rng.Left, Rng.Top, Rng.Width, Rng.Height)
        Rng.Offset(0, 1).Value = PicList(lLoop)     'Pic Name
        xRowIndex = xRowIndex + 1

Bye
 

Watch MrExcel Video

Forum statistics

Threads
1,119,102
Messages
5,576,135
Members
412,699
Latest member
Dmetcalf2021
Top