I have VBA code (see below) that inserts a picture. The issue is that when I send the Excel file to someone else, the pictures do not show up and they get the error in place of the picture (see below image) when they open the Excel file. Is there something that can be put in the VBA code that 'de-links' the image from my directory?
Appreciate any help you can give me!
Appreciate any help you can give me!
VBA Code:
Sub InsertPic()
'Make all pictures move and size with cell
Dim xPic As Picture
On Error Resume Next
Application.ScreenUpdating = False
For Each xPic In ActiveSheet.Pictures
xPic.Placement = xlMoveAndSize
Next
Application.ScreenUpdating = True
'Add picture...centered...scaled
Dim fNameAndPath As Variant
Dim rng As Range
Dim img As Picture
fNameAndPath = Application.GetOpenFilename( _
FileFilter:="Image Files (*.gif;*.jpg;*.png), *.gif;*.jpg;*.png", _
Title:="Select an Image", _
ButtonText:="Select")
If fNameAndPath = False Then Exit Sub
Set rng = ActiveCell
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
With img
If .Width > .Height Then
.Width = rng.Width * 0.7
Else
.Height = rng.Height * 0.7
End If
.Left = rng.Left + (rng.Width - .Width) / 2
.Top = rng.Top + (rng.Height - .Height) / 2
.Placement = 1
.PrintObject = True
End With
End Sub