Inserting a picture into a shape macro issues

exel123

New Member
Joined
Jul 22, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I am trying to insert pictures into shapes in a spread sheet I have. I would like for the macro to bring up the file explorer and allow me to manually select the picture instead of specifying the image name in the macro. Any help would be greatly appreciated!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
This works for me.
Change references where required
Code:
Sub Fill_Oval()
Dim strFilePath As String
    With Application.FileDialog(msoFileDialogFilePicker)
        If .Show <> 0 Then
            strFilePath = .SelectedItems(1)
            With ActiveSheet.Shapes("Oval 4").Fill
                .Visible = msoTrue
                .UserPicture strFilePath
            End With
        End If
    End With
End Sub
 
Upvote 0
Thank you for letting us know.
In your first post you mentioned pictures and shapes (multiple of each)
If you have the folder name where the pictures are stored (C:\Users\PeterPuck\Pictures) in cell D1 and
the names of the shapes in column J starting at J2 (header in J1) and
the picture names, in this case without extension, in column O on the same line as the representing shapes,
following will fill all the shapes with the corresponding pictures.
If you want to use it, change references where required.
Code:
Sub InsertPics_In_Shapes()
  Dim i As Long, lr As Long
  lr = Range("J" & Rows.Count).End(xlUp).Row
  For i = 2 To lr
    ActiveSheet.Shapes(Range("J" & i).Value).Fill.UserPicture Range("D1").Value & "\" & Range("O" & i).Value & ".jpg"
  Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,749
Members
449,050
Latest member
excelknuckles

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