Hello.
I'm pretty naive when it comes to VBA. A coworker of mine made me a code to insert images into an excel.
Since the images are pulled from a local drive, the file cannot be emailed and shared.
I've been reading that I need to change the code to Shapes.AddPicture. I just don't know how/where in my current code to make those adjustments.
I appreciate your help!
'Declarations
Sub Picmac()
Application.ScreenUpdating = False
ActiveSheet.Pictures.Insert("M:\Retail and Merchandising\Merchandising Retail\Armani Outlets\Allocations\Photos\" & "sample" & ".jpg").Select
ActiveSheet.Shapes.SelectAll
Selection.Delete
Dim myLink As String
Dim mypic As String
Dim mypicecom As String
Dim cellpos As String
Dim Picture As String
Dim PictureEcom As String
Dim lastrow As Long
With Worksheets("Allocation Tool")
lastrow = .Cells(Rows.Count, "D").End(xlUp).Row
End With
Dim rng As Range: Set rng = ActiveSheet.Range("D9:D" & lastrow)
Dim I As Integer
For I = 9 To lastrow
Picture = Sheets("Allocation Tool").Range("C" & I).Value
mypicecom = "M:\Retail and Merchandising\Merchandising Retail\Armani Outlets\Allocations\Photos\AO SS19 Photos\" & Picture & ".jpg"
cellpos = Sheets("Allocation Tool").Range("B" & I).Value
Debug.Print cellpos
On Error Resume Next
Application.CutCopyMode = False
ActiveSheet.Pictures.Insert(mypicecom).Select
With Selection
Selection.LockAspectRatio = msoFalse
Selection.Top = Range(cellpos).Top
Selection.Left = Range(cellpos).Left
Selection.Width = Range(cellpos).Width
Selection.Height = Range(cellpos).Height
End With
Next
Application.ScreenUpdating = True
End Sub
Bookmarks