View Single Post
 
Old 01-31-2017, 09:48 AM
beyondimage beyondimage is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Jan 2017
Posts: 1
beyondimage is on a distinguished road
Default Insert multiple images at once from a folder

Good morning everyone!

So I have taken this code from https://www.extendoffice.com/documen...-pictures.html as it should be seen below.

What I want to know is if anyone can help me with -

Having all the photos import across 'Row B', instead of in a column fashion.
And how to add the 'File Names' (i.e. excel_image2.jpg) of said images, above each of their image in 'Row A'.
Thanks for all the help ahead of time!

Code:
Sub InsertPictures()
'Update 20140513
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
Reply With Quote