Macro to embed images in excel 2013 doesn't show images when e-mailing file to someone else

rohanvor

New Member
Joined
May 2, 2013
Messages
3
Hello,
I have a macro that searches a folder on my desktop for a particular image and then inserts it into a designated column.
Sku's listed are in column D. Respective images get inserted into column C.

Sub ProcessFiles()
Dim sPath As String, s As String, r As Range
Dim shp As ShapeRange
Dim c As Range, cell As Range, sname As String
Dim p As Picture, diffwidth As Double, diffHeight As Double
sPath = "C:\Users\Dan\Pictures\<wbr>inventory pictures\"
If Right(sPath, 1) <> "\" Then sPath = sPath & "\"
Set r = Range("D1", Cells(Rows.Count, "D").End(xlUp))
For Each cell In r
cell.Offset(0, 1).Select
Set c = cell.Offset(0, -1)
s = sPath & cell.Value & ".jpg" 'remove the .jpg if the cell contains the extension
sname = Dir(s)
If sname <> "" Then
Set p = ActiveSheet.Pictures.Insert(s)
Set shp = p.ShapeRange
'shp.ScaleHeight Factor:=0.5, RelativeToOriginalSize:=<wbr>msoTrue
shp.Height = 100
If shp.Height > 409 Then
cell.EntireRow.RowHeight = 409
Else
cell.EntireRow.RowHeight = shp.Height
End If
p.Left = c.Left
p.Top = c.Top

End If
Next

End Sub


This works fine in my workbook but when I send the file to a co-worker, they are unable to see the images. They get an error message where the images should be. Is this because the macro does not actually embed the image into the file?

Caveat: When the macro is run on an excel 2003 version (I am using 2013), it works fine and everyone I send the file to can see the images. I ready somewhere that there were some VBA compatibility issues for MS Office 2010 and higher.

Can anyone help solve this mystery?

Thanks!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

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