0

I have the following code for inserting images in Excel, but when I sent the file to the users out of the network, they are not able to see the pictures. Is there any way to modify the code, so as it will be not link, but embedded image? Here is the code:

Private Sub Worksheet_Change(ByVal Target As Range)
If (Target.Count > 1) Or (Split(Target.Address, "$")(1) <> "A") Then Exit Sub

Dim c As Range
Dim myPath As String
myPath = "P:\"
Application.ScreenUpdating = False

For Each c In Target.Cells
    If Not Dir(myPath & "*" & c.Text & "*") = "" Then
        InsertPicture myPath & Dir(myPath & "*" & c.Text & "*"), c.Offset(0, 1)
    End If
Next c
Application.ScreenUpdating = True

End Sub


Sub InsertPicture(thePath As String, theRange As Range)

With ThisWorkbook.ActiveSheet.Pictures.Insert(thePath)
    With .ShapeRange
    .LockAspectRatio = msoTrue
    .Width = theRange.Width
    .Height = theRange.Height
End With
    .Left = theRange.Left
    .Top = theRange.Top
    .Placement = 1
    .PrintObject = True
End With

End Sub

Thank you!

Monika
  • 61
  • 8
  • 2
    Here is a link to answer your question: [VBA to insert embedded picture excel](https://stackoverflow.com/q/17110425/5162073) – Brian M Stafford Aug 14 '17 at 15:50
  • 3
    Possible duplicate of [VBA to insert embedded picture excel](https://stackoverflow.com/questions/17110425/vba-to-insert-embedded-picture-excel) – John Coleman Aug 14 '17 at 16:35

0 Answers0