Bysystemroad
New Member
- Joined
- Jun 1, 2020
- Messages
- 9
- Office Version
- 365
- Platform
- Windows
Dear Users
You can see the VBA code that ı use in the below.
But ı need to transform to "ActiveSheet.Shapes.AddPicture" style.
I use in the below code for to take the photos in the relevant folder, which corresponds to the product codes in column B, put pictures to column A with.
But when ı send to my customer, they can't see pictures in the excel .
You can see the VBA code that ı use in the below.
But ı need to transform to "ActiveSheet.Shapes.AddPicture" style.
I use in the below code for to take the photos in the relevant folder, which corresponds to the product codes in column B, put pictures to column A with.
But when ı send to my customer, they can't see pictures in the excel .
VBA Code:
Sub InsertPictures()
Dim objPic As Picture, i As Long
Dim sPath As String, sFile As String
sPath = "C:\Users\canberk.saka\Desktop\SS20 FOTOĞRAFLARI\SS 2020 IMAGES\SS20 FOTOS\"
If Dir(sPath, vbDirectory) = "" Then
MsgBox "This directory does not exist"
Exit Sub
End If
On Error Resume Next
For Each objPic In ActiveSheet.Pictures
If objPic.Name Like "img_*" Then
objPic.Delete
End If
Next
On Error GoTo 0
For i = 4 To Range("B" & Rows.Count).End(3).Row
sFile = Range("B" & i).Value & ".jpg"
If Dir(sPath & sFile) <> "" Then
Set objPic = ActiveSheet.Pictures.Insert(sPath & sFile)
With Range("A" & i)
objPic.ShapeRange.LockAspectRatio = msoFalse
objPic.Top = .Top
objPic.Left = .Left
objPic.Width = .Width
objPic.Height = .Height
objPic.Name = "img_" & i
End With
End If
Next
End Sub